简体   繁体   中英

How do I show the Excel Save Changes Dialog

I am handling an OnWorkbookBeforeClose event and need to prompt the user to save changes. There is plenty on how to disable the Save Changes Dialog, but nothing on how to show it...

(I need to tidy some things up. If do so then get Excel to put this box up and the user presses cancel, there is no event that the user has not saved the workbook and it is still open and active).

Since there are no DialogButtons for a standard Dialog for SaveDontSaveCancel (closest is YesNoCancel) is there any way of showing this Save Changes Dialog?

(To be clear I am not interested in the Save or SaveAs dialogs, only the 'Save Changes' dialog which prompts: 'Do you want to save the changes to Book1.xks? and has 3 buttons: Save, Don't Save, Cancel)

The XlBuiltInDialog.xlDialogSaveWorkbook simply shows the Save dialog prompting for a file name (implying the user has already chosen 'Save').

Alternatively if there is an event raised after a workbook is closed then this would allow me to do what I need.

I would rather present the user with the correct Excel Dialog so don't really want to roll my own.

You might set the Saved property of the workbook to False in the Workbook_BeforeClose event. This would force Excel to display the Save/Don't Save/Cancel dialog @Siddharth mentioned after the event returns. If the user chooses Cancel, the workbook will remain open. Is that what you want?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM