Deleting code in a file with code..
Hi ,
I am running this bit of code below from an addin file that deletes the code
in Sheet 1 of the active workbook.
It works fine..except for the Save part.
After I run this codes and file closes... I open the file back up and it
prompts to enable macros... There are no macros in the workbook anymore (i
checked)... and if I click on the Save button in Excel, close that file, and
then open it up again.. it doesn't prompt to enable macros..
I need to be able to run this code.. have the file save and close and then
when it's opened back up.. the enable macro message will not appear
..
The only way I have been able to get this to work is by taking out the
"activeworkbook.close" section of the code and then..after the code runs.. I
click the Save button in Excel and then close it myself.
Does anyone know why this is happening???
If ActiveWorkbook.VBProject.vbComponents("Sheet1").Co demodule.CountofLines
0 Then
With ActiveWorkbook.VBProject.vbComponents("Sheet1").Co demodule
.DeleteLines 1, .CountofLines
End With
Else
MsgBox prompt:="No Code to Delete!"
End If
Activeworkbook.Save
Activeworkbook.Close true
End Sub
Thanks in advance for your help...
Kimberly
|