4
votes

Using Application.Quit in Excel VBA is supposed to initiate the default quit procedure, which includes prompting the user to saved any unsaved documents currently open in the application.

In testing across numerous systems (Excel 2010 32-bit, Windows 7 64-bit), I discovered that some systems prompt the user to save, and some systems do not.

We checked the settings across the systems (including enabling all macros and disabling protected view) to no avail. Even using the same settings on the different systems did not force the one system to prompt the user to save their work before Excel shuts down.

It's as if Application.DisplayAlerts has been set to False, but it hasn't. We even tried the following lines of code:

Application.DisplayAlerts = True
Application.Quit

On certain systems, even that still doesn't prompt the user to saved unsaved documents. Excel just suddenly shuts down.

Any help solving this is greatly appreciated.

Thanks!

Update in response to comments:

I double checked the Workbooks.Saved property for all the workbooks that were opened and unsaved and it was false just before Application.Quit, so that must not be the problem.

I also just ran a simple test. I opened a workbook, edited it and executed Application.Quit in the immediate window in VBA. Excel quit without prompting to save the unsaved file. This indicates to me that it is something about my Excel setup and has nothing to do with my application.

3
Could something have set ActiveWorkbook.Saved = True or similar?Jon Hanna
Prior to the quit I would add this line ActiveWorkbook.Saved = False (to test a single workbook - if this works then the code would need to be updatd to loop through all open workbooks and to change their saved status). But this is clearly a hack as the save message should be flagged without code, I haven't come accross this before, I will look further into the other Excel forums to see if someone else has experienced it.brettdj
Are you maybe quitting without having changed anything the workbook? Because Excel won't prompt you to save if you haven't changed anything, regardless of the status of DisplayAlerts.Jean-François Corbett

3 Answers

5
votes

Disabling the Solver Add-In returns the normal behavior.

0
votes

I tried the same thing of disabling the Solver Add-In and that did not work. I decided to also try disabling the Hstbar Add-In. Both of them disabled made the prompt start working again.

0
votes

I was using the following code to save the workbook and close the application

ActiveWorkbook.Save
Application.Quit

but after a crash excel asked me to disable the Solver. After disabling the solver Excel didn't recognise the save command and it was continuing to ask if I wanted to save the workbook despite the save command.

Then I have figured out that this bug could be solved by enable again the solver...

very weird