Hi all
Heres a Brain teaser:
I have a spreadsheet that I copy through code and then edit the copy and delete the macros. The reason I want the macros delted on the copy is because I am sending it over e-mail and some of the exhange servers of the people I am sending it to do not allow VB code in attachments and so reject the mail.
Here is my code:
Module 2, 5, and 8 will delete however module 1 won't. I believe that this is related to the fact that the code above resides in module 1 in the master copy. Now to set one thing right I am running the code on the master copy so I am not trying to delete the same macro I am running.
I did atttempt to put code in module 5 to delete module 1 but then it didn't remove module 1 and 5.
I have used the following code to delete the text:
And this works but the module still stays there, it wont delete.
So where I am so far is that as far as I am aware I can get rid of all the VB code, but because there is a module there Excel still pops up a warning message when I open it saying that there is a macro on the spreadsheet and do I want to enable it.
So my question is:
Heres a Brain teaser:
I have a spreadsheet that I copy through code and then edit the copy and delete the macros. The reason I want the macros delted on the copy is because I am sending it over e-mail and some of the exhange servers of the people I am sending it to do not allow VB code in attachments and so reject the mail.
Here is my code:
Code:
Application.Workbooks(savename & ".xls").VBProject.VBComponents.Remove Application.Workbooks(savename & ".xls").VBProject.VBComponents("Module1")
Application.Workbooks(savename & ".xls").VBProject.VBComponents.Remove Application.Workbooks(savename & ".xls").VBProject.VBComponents("Module2")
Application.Workbooks(savename & ".xls").VBProject.VBComponents.Remove Application.Workbooks(savename & ".xls").VBProject.VBComponents("Module5")
Application.Workbooks(savename & ".xls").VBProject.VBComponents.Remove Application.Workbooks(savename & ".xls").VBProject.VBComponents("Module8")
Module 2, 5, and 8 will delete however module 1 won't. I believe that this is related to the fact that the code above resides in module 1 in the master copy. Now to set one thing right I am running the code on the master copy so I am not trying to delete the same macro I am running.
I did atttempt to put code in module 5 to delete module 1 but then it didn't remove module 1 and 5.
I have used the following code to delete the text:
Code:
Set VBCodeMod = Application.Workbooks(savename & ".xls").VBProject.VBComponents("Module1").CodeModule
With VBCodeMod
StartLine = 1
HowManyLines = .CountOfLines
.DeleteLines StartLine, HowManyLines
End With
And this works but the module still stays there, it wont delete.
So where I am so far is that as far as I am aware I can get rid of all the VB code, but because there is a module there Excel still pops up a warning message when I open it saying that there is a macro on the spreadsheet and do I want to enable it.
So my question is:
[COLOR=red yellow]
How do I Remove module 1?
[/color]
]How do I Remove module 1?
[/color]