vba 关闭 Word 时禁用保存提示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13294950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 18:25:15  来源:igfitidea点击:

Disable Save prompt when closing Word

vbams-word

提问by Daevin

I'm trying to make it so that when a user clicks the "X" in the top right corner of a WORD document, the prompt "would you like to save changes?" does not come up and the document is not saved. I have found many solutions for Excel, but I have not been successful trying to apply them to Word...

我试图做到这一点,当用户单击 WORD 文档右上角的“X”时,提示“您要保存更改吗?” 没有出现,文档也没有保存。我找到了许多Excel解决方案,但我没有成功地尝试将它们应用于 Word...

Thanks in advance for any help!

在此先感谢您的帮助!

EDIT:I want this to apply to only one document. The .docm is set up as a ReadOnly (to allow Kill-ing itself); it has 2 buttons, 1 for saving as a .pdf form for retain, and 1 to save as a revision and not a completed form. I want to disable the prompt when someone uses the "X" to force saved revision tracking.

编辑:我希望这仅适用于一个文件。.docm 设置为 ReadOnly(以允许 Kill-ing 本身);它有 2 个按钮,1 个用于保存为 .pdf 表单以供保留,1 个用于保存为修订版而不是完整的表单。当有人使用“X”强制保存修订跟踪时,我想禁用提示。

回答by Kevin Pope

Put this in your ThisDocumentObject under MicrosoftWordObjectsfor the file in question.

把它放在你的ThisDocument对象下,MicrosoftWordObjects用于有问题的文件。

Make sure it doesn't go into the Normalsection

确保它不会进入该Normal部分

Private Sub Document_Close()
    Me.Saved = True
End Sub

Putting this in the Normalsection will turn off the Save As functionality for all documents you open on your instance of Word.

将其放在该Normal部分将关闭您在 Word 实例上打开的所有文档的另存为功能。