简体   繁体   English

如何显示“ Excel保存更改”对话框

[英]How do I show the Excel Save Changes Dialog

I am handling an OnWorkbookBeforeClose event and need to prompt the user to save changes. 我正在处理OnWorkbookBeforeClose事件,需要提示用户保存更改。 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). (我需要整理一些东西。如果这样做,则使Excel放好该框,然后用户按Cancel,就不会发生用户尚未保存工作簿且它仍处于打开和活动状态的事件)。

Since there are no DialogButtons for a standard Dialog for SaveDontSaveCancel (closest is YesNoCancel) is there any way of showing this Save Changes Dialog? 由于没有用于SaveDontSaveCancel的标准对话框的DialogBu​​ttons(最近的是YesNoCancel),有没有办法显示此Save Changes对话框?

(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) (为清楚起见,我对“保存”或“另存为”对话框不感兴趣,只有“保存更改”对话框提示:“您是否要将更改保存到Book1.xks?并具有3个按钮:“保存”,“不保存”,“取消)

The XlBuiltInDialog.xlDialogSaveWorkbook simply shows the Save dialog prompting for a file name (implying the user has already chosen 'Save'). XlBuiltInDialog.xlDialogSaveWorkbook仅显示“保存”对话框,提示输入文件名(暗示用户已选择“保存”)。

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. 我宁愿为用户提供正确的Excel对话框,因此,我真的不想自己动手。

You might set the Saved property of the workbook to False in the Workbook_BeforeClose event. 您可以在Workbook_BeforeClose事件中将工作簿的Saved属性设置为False This would force Excel to display the Save/Don't Save/Cancel dialog @Siddharth mentioned after the event returns. 这将迫使Excel在事件返回后显示@Siddharth的“保存/不保存/取消”对话框。 If the user chooses Cancel, the workbook will remain open. 如果用户选择“取消”,则工作簿将保持打开状态。 Is that what you want? 那是你要的吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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