如何使用VBA禁用MS Word 2010/2013中的“另存为”按钮
使用VBA,我想禁用(或隐藏)MS Word 2013中“文件”菜单中显示的“保存”和“另存为”按钮,以便用户无法单击它们 我已尝试使用以下方法禁用这些按钮:如何使用VBA禁用MS Word 2010/2013中的“另存为”按钮,vba,Vba,使用VBA,我想禁用(或隐藏)MS Word 2013中“文件”菜单中显示的“保存”和“另存为”按钮,以便用户无法单击它们 我已尝试使用以下方法禁用这些按钮: Word.CommandBars("File").Controls("&Save").Enabled = False Word.CommandBars("File").Controls("&Save").Visible = False 但这没有效果。有什么方法可以禁用这些按钮吗?您可以在保存事件之前使用工作簿 自200
Word.CommandBars("File").Controls("&Save").Enabled = False
Word.CommandBars("File").Controls("&Save").Visible = False
但这没有效果。有什么方法可以禁用这些按钮吗?您可以在保存事件之前使用
工作簿
自2007版以来,“菜单控件”不再通过CommandBars对象模型进行控制。因此,要控制菜单项,我必须定义功能区XML,该XML必须合并到文档中,或者作为外接程序的一部分加载
要在Word 2010中禁用Save和SaveAs,我使用以下XML代码:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<commands>
<command idMso="FileSave" enabled="false" />
<command idMso="FileSaveAsMenu" enabled="false" />
<command idMso="FileSaveAsWordDocx" enabled="false" />
<command idMso="FileSaveAsWordDotx" enabled="false" />
<command idMso="FileSaveAs" enabled="false" />
<command idMso="FileSaveAsWord97_2003" enabled="false" />
<command idMso="FileSaveAsPdfOrXps" enabled="false" />
<command idMso="FileSaveAsOtherFormats" enabled="false" />
<command idMso="FileSaveToDocumentManagementServer" enabled="false" />
<command idMso="SaveSelectionToQuickPartGallery" enabled="false" />
<command idMso="FrameSaveCurrentAs" enabled="false" />
<command idMso="FileSaveAsWordOpenDocumentText" enabled="false" />
</commands>
</customUI>
我用于执行和测试此代码。这为如何使用自定义UI编辑器提供了很好的培训
谢谢你的快速回复。我正在尝试这个。但是您确定这也会禁用“保存”按钮吗?@rsKRISH它不会禁用“保存”按钮。但当你点击“保存”按钮时,工作簿将不会被保存。好的,谢谢Santosh。但是有什么方法我可以禁用保存按钮吗?@rsKRISH我相信这是更好的方法。是的,毫无疑问这是更好的方法,但我也需要禁用按钮。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<commands>
<command idMso="FileSave" enabled="false" />
<command idMso="FileSaveAsMenu" enabled="false" />
<command idMso="FileSaveAsWordDocx" enabled="false" />
<command idMso="FileSaveAsWordDotx" enabled="false" />
<command idMso="FileSaveAs" enabled="false" />
<command idMso="FileSaveAsWord97_2003" enabled="false" />
<command idMso="FileSaveAsPdfOrXps" enabled="false" />
<command idMso="FileSaveAsOtherFormats" enabled="false" />
<command idMso="FileSaveToDocumentManagementServer" enabled="false" />
<command idMso="SaveSelectionToQuickPartGallery" enabled="false" />
<command idMso="FrameSaveCurrentAs" enabled="false" />
<command idMso="FileSaveAsWordOpenDocumentText" enabled="false" />
</commands>
</customUI>