LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default delete macro and auto save/quit

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove all macros and objects in Excel, Save and Quit [email protected] Excel Programming 0 June 2nd 06 12:38 PM
Remove all macros and objects in Excel, Save and Quit [email protected] Excel Discussion (Misc queries) 0 June 2nd 06 12:24 PM
2 Part question involving SaveAs and Auto Save when quit. ryanmhess Excel Programming 0 September 1st 05 09:47 PM
Application.Quit still wants to save phreud[_23_] Excel Programming 0 July 2nd 04 12:24 PM
auto save as macro Kelly[_3_] Excel Programming 0 July 30th 03 04:26 PM


All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"