Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
All -
I have been learning about how to delete macros in vba. It works. But take a look at this code (in "Module1"): Sub delete_save_quit() Dim vbCom As Object Set vbCom = Application.VBE.ActiveVBProject.VBComponents Application.DisplayAlerts = False vbCom.Remove VBComponent:= _ vbCom.Item("Module1") ActiveWorkbook.Save Application.Quit ' Application.DisplayAlerts = True End Sub Problem looking for a solution: I want to remove the module, and also save and quit automatically since I am running excel via the command line (.bat file). As a note, what follows is true even when I rename the subroutine to "Auto_Open", which is what I want since everything needs to be automated...opening the workbook, (running some macros), deleting the entire module, saving, quitting. Here is the behavior of this subroutine: Since I do not want to be prompted to save the workbook, I set DisplayAlerts=False. If I do this, the module is not deleted, but the workbook is saved (modified date is updated). If I do not DisableAlerts, I will be prompted to save, but the module WILL be deleted upon saving. It doesn't seem to matter where I put the DisplayAlerts=False...before the "Set" or after the "Remove" doesn't change the behavior I am seeing either. Lastly, I thought that I may need to DisplayAlerts=True for some reason, so I would also try adding the line at the end of the above subroutine. All this does is prompt me to save (this is after the code says 'save' and 'quit')! help please...sounds like there are some great vba programmers here... -- - chris |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Remove all macros and objects in Excel, Save and Quit | Excel Programming | |||
Remove all macros and objects in Excel, Save and Quit | Excel Discussion (Misc queries) | |||
2 Part question involving SaveAs and Auto Save when quit. | Excel Programming | |||
Application.Quit still wants to save | Excel Programming | |||
auto save as macro | Excel Programming |