Kuyenda
Kuyenda

Reputation: 4609

Excel doesn't prompt to save unsaved files on Application.Quit

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.

Upvotes: 4

Views: 6366

Answers (3)

Jpi
Jpi

Reputation: 1

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

Upvotes: 0

Cole Walker
Cole Walker

Reputation: 1

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.

Upvotes: 0

Kuyenda
Kuyenda

Reputation: 4609

Disabling the Solver Add-In returns the normal behavior.

Upvotes: 5

Related Questions