【问题标题】:Disable the Save As Button in Word 2010在 Word 2010 中禁用“另存为”按钮
【发布时间】:2012-10-15 23:43:53
【问题描述】:

我有以下代码应该禁用 Word 2010 中的“另存为”按钮。在 Document_Startup 事件中调用以下方法:

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;
}

我希望“另存为”按钮显示为灰色,但事实并非如此,它仍然有效。我做错了什么?

【问题讨论】:

标签: c# interop word-2010


【解决方案1】:

我想通了。我只需要使用以下信息将功能区 XML 项添加到项目中。我还需要禁用其他一些按钮:

     <?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>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多