I am trying to write a macro that will delete the code behind a particular worksheet. I tried the following code but I keep getting a compile error after it deletes the lines.
Code Code:
Dim VBProj As VBIDE.VBProject Dim VBComp As VBIDE.VBComponent Set VBProj = ActiveWorkbook.VBProject Set CodeMod = ActiveWorkbook.VBProject.VBComponents("sheet1").CodeModule CodeMod.DeleteLines 1, CodeMod.CountOfLines
First I get the following compile error:
"Only comments may appear after End Sub, End Function, or End Property"
I click "OK" and then I get the following run-time error:
"Method '_Default' of object 'Range' failed."
Regardless if I hit Debug or End, the program closes.
Any help is appreciated.
Chrissy




Reply With Quote