You can exit or close Excel without asking the user to save by setting display alerts to False and calling Application.Quit. Here’s some simple example code to exit Excel without prompting the user to save:
Sub ExitWithoutPrompt()
Application.DisplayAlerts = False
Application.Quit
End Sub
October 24th, 2004 at 2:47 pm
but would you want to?????!
October 26th, 2004 at 8:38 am
Most of the time I post whatever comes to mind or from notes, however sometimes I post relating to people searching this site for topics I haven’t covered, this is the case with this post.
I can’t think of many practical reasons for doing this however - possibly a calculator template that a user can manipulate but should exit without saving the current state?
December 15th, 2004 at 10:53 am
maybe - sounds like trouble to me though! - even if you’ve cerated a new instance of the excel object
November 12th, 2008 at 9:54 pm
This is just what I was looking for.
Thanks
December 4th, 2008 at 1:41 am
@ross, mark.
Might not be particularly useful in general Excel use, but has a fantastic use in programming Excel from other applications using COM automation.
appExcel.DisplayAlerts = False
appExcel.Quit
Inside the exception procedure if something else gets ballsed up. This prevents having a hundred EXCEL.EXE processes in the background while you’re debugging, because every “New Excel.Application” spawns a new Excel process.