Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Excel 2019 still displays save prompt even when the Application.EnableEvents = False

I tried all the different blocks of codes below but when I close the Excel, it still prompts whether to save or not.

I have the code in the Workbook BeforeClose event.
I am using excel 2019 and Windows 11

I tried this,

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.Saved = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True

this,

Application.DisplayAlerts = False
ThisWorkbook.Saved = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True

and this,

Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True

Am I missing something?

>Solution :

Application.Calculation = xlCalculationAutomatic is a workbook change. Hence the previous saved state is no longer valid. You can confirm this easily enough my doing the same thing manually. i.e. toggle calculation state after a save and attempt to close the book.

Interestingly enough, it you save one book with Auto calc on and close it. Then save another with Auto calc off and close it. The calc state will be reflected by whichever you next open. That is to say, it’s saved in the workbook (not the application). Excel resolves conflicts by adopting the current state to any subsequent books opened.

This isn’t new by the way. Been like that as long as I can remember. Which, unfortunately, is too long 🙂

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading