在Word 2010中禁用“另存为"按钮 [英] Disable the Save As Button in Word 2010

查看:294
本文介绍了在Word 2010中禁用“另存为"按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码应禁用Word 2010中的另存为"按钮.Document_Startup事件中正在调用以下方法:

I have the following code that should disable the Save As button in Word 2010. The method below is being called in the Document_Startup event:

private void DisableSaveAsButton()
{
    Object MenuBar = 40;
    Object FileMenu = 1;
    Object SaveAsButton = 5;
    var saveAsBtn = this.ThisApplication.CommandBars[MenuBar].Controls[FileMenu].accChild[SaveAsButton] as CommandBarButton;
    saveAsBtn.Enabled = false;
}

我希望另存为"按钮显示为灰色,但事实并非如此,它仍然可以运行.我在做什么错了?

I am expecting the Save as Button to be grayed out, but it isn't and it still functions. What am I doing wrong?

推荐答案

我知道了.我只需要使用以下信息将Ribbon XML项目添加到项目中.我还需要禁用其他一些按钮:

I figured it out. I just had to add a Ribbon XML item to the project with the following info below. I also needed to disable a few other buttons:

     <?xml version="1.0" encoding="UTF-8"?>
     <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" 
        onLoad="OnLoad" > 
        <commands> 
          <command idMso="FileSaveAs" enabled="false" />
          <command idMso="FileNewDefault" enabled="false"/>
          <command idMso="FileOpen" enabled="false"/>
          <command idMso="FileOpenRecentFile" enabled="false"/>
        </commands> 
     </customUI>

这篇关于在Word 2010中禁用“另存为"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆