MrExcel Consulting
Your One Stop for Excel Tips & Solutions

Quit Method


Posted by Dennis on July 31, 2001 9:06 AM

I have an excel application that has a simple exit command to quit the application (Application.Quit). Unfortunately, this only closes my workbook and leaves Excel2000 open. It works fine if I remove the following

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.Close SaveChanges:=False
End Sub

but I do not want be prompted to save changes. Does anyone have any suggestions for a nice clean exit routine?

Thank you.

Posted by Russell on July 31, 2001 9:27 AM

Just put code above your application.quit command:

ActiveWorkbook.Close False
Application.Quit

Hope this helps,

Russell

Posted by Dennis on July 31, 2001 10:00 AM


I'm still getting the same results. My Excel application will quit but I'm left with Excel open with no worksheets showing. Any other suggestions?

Posted by Russell on July 31, 2001 10:19 AM

Ok, what's happening is that when the workbook closes, the macro closes with it (therefore it never sees the Application.Quit line). I tried reversing the lines and it worked:

Application.Quit
ActiveWorkbook.Close False

Let me know if it doesn't work for you,

Russell

Posted by Russell on July 31, 2001 10:20 AM

Make sure you save your workbook before running code!

After you change the lines, make sure you save the workbook since you are telling it not to save changes when you quit! : Just put code above your application.quit command:

Posted by Dennis on July 31, 2001 12:28 PM

Beautiful! Thanks for your help Russel.