Can I save a spreadsheet without the VBA code?
Can I save a spreadsheet without the VBA code?
(OP)
I have a small VBA progam in an Excel spreadsheet that helps the user set up the worksheets. Once they save the spreadsheet to a new file there is no use for the program but it still gives the Disable/Enable Macros warning. Is there a way to save the Excel workbook without the VBA program?





RE: Can I save a spreadsheet without the VBA code?
Instead could you use your macro to create a New file? Or look into calling the macro from the personal.xls file or creating a Add-In (.xla).
Ken
RE: Can I save a spreadsheet without the VBA code?
RE: Can I save a spreadsheet without the VBA code?
Code associated with "Microsoft Excel Objects" (ie worksheets etc) has to be deleted explicitly, by selecting then deleting the lines of code.
Code in modules can be similarly deleted, but that leaves the module behind, and the module's presence will cause your enable/disable message to appear on opening. To delete the module itself (as well as its contents) right-click on the module's name where it appears on the right hand side of the screen, then select "Remove..." from the options offered.
RE: Can I save a spreadsheet without the VBA code?
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: Can I save a spreadsheet without the VBA code?
RE: Can I save a spreadsheet without the VBA code?
in the new file go to tool--macros and click run macros. your original macro in the OPEN ORIGINAL FILE will show up. run it and save your new file with what ever name you want. close your original file
RE: Can I save a spreadsheet without the VBA code?
RE: Can I save a spreadsheet without the VBA code?
http://www.ozgrid.com/VBA/delete-module.htm
Excel VBA: Delete Module After Running VBA Code. Deleting Modules via VBA Code
Delete Module via Code. See Also Delete Sheet Event Code With Code & Delete Workbook Event Code
The code below can be used to delete the module which houses the code. In other words, it deletes itself after running once.
You will have to go to Tools>Macro>Security - Trusted Publishers and check Trust access to Visual Basic Editor before running the code. Change "Module1" to suit.
Sub DeleteThisModule()
Dim vbCom As Object
MsgBox "Hi, I will delete myself "
Set vbCom = Application.VBE.ActiveVBProject.VBComponents
vbCom.Remove VBComponent:= _
vbCom.Item("Module1")
End Sub
RE: Can I save a spreadsheet without the VBA code?
Ken