View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
david mcritchie david mcritchie is offline
external usenet poster
 
Posts: 691
Default Code & modules are gone, Macro warning message remains

Hy Byron,
Take a look at Chip Pearson's
Deleting All VBA Code In A Project
http://www.cpearson.com/excel/vbe.htm

If he missed something, I'm sure he would be interested.
But you will see that it deletes Standard Modules, Forms,
Class Modules as well as emptying sheets of code.

I believe you did not remove the forms.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Byron" wrote in message ...
I have an Excel Workbook where users can fill out a form and then press a
command button on the Sheet that saves a copy of the file into a pre-defined
directory. I don't want the copied version of the Workbook to have any of the
VBA code or the command button in it so I tried to remove them using the
following code inside the copy subroutine:
...
With ActiveWorkbook.VBProject.VBComponents("Sheet1").Co deModule
.DeleteLines 1, .CountOfLines
End With
ActiveWorkbook.ActiveSheet.OLEObjects("My_Button") .Delete
...
The code and the button are removed just fine from the copied file, but when
I open the new copy of the Workbook, Excel gives me the Macro warning
message. I have checked in the Visual Basic Editor and there are no
additional modules attached to the Workbook and there is no code in any of
the Sheet modules or the ThisWorkbook module.

How can I completely get rid of the button and code so that I no longer get
the Macro warning message?

Thanks in advance.