自定义功能区XML选项卡未显示在WORD VSTO加载项中

时间:2017-04-04 17:21:58

标签: visual-studio-2015 ms-word vsto word-addins

我按照此MSDN Tutorial创建了WORD 2010 VSTO AddIn 标签。我正在使用VS2015 Community Edition。当我在Visual Studio中运行应用程序时,它会打开Word文档但Tab不会显示在WORD中(正如turorial的测试步骤所声称的那样)。所以,我无法测试AddIn。

但是,我可以在WORD的COM加载项窗口中看到上面的AddIn - 如下图所示。此外,当我在以下过程中放置​​断点时,我可以看到成功调用此过程。 注意:我通过复制/粘贴代码,项目名称等逐字逐句地遵循教程。所以,我没有从教程中改变任何内容。

protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
     return new MyRibbon();
}

enter image description here

更新 MyRibbon.xml 如下所示。

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <ribbon>
    <tabs>
      <tab idMso="TabAddIns">  
        <group id="ContentGroup" label="Content">  
            <button id="textButton" label="Insert Text"  
                 screentip="Text" onAction="OnTextButton"  
                 supertip="Inserts text at the cursor location."/>  
            <button id="tableButton" label="Insert Table"  
                 screentip="Table" onAction="OnTableButton"  
                 supertip="Inserts a table at the cursor location."/>  
        </group>  
      </tab> 
    </tabs>
  </ribbon>
</customUI>

更新2 :在通过下面的@dotNET阅读评论后,我认为问题似乎是我的WORD文档缺少内置ADD-INS。如何显示ADD-INS标签?在WORD的自定义标签选项中,我没有看到该标签,如下图所示。我应该在哪里看?

enter image description here

1 个答案:

答案 0 :(得分:3)

您的按钮将使用您提供的代码添加到内置ADD-INS标签中。如果您需要自己的自定义标签,请不要使用idMso。而是像这样定义<tab>节点:

<tab id="tabMyVeryOwnCustomTab" label="TRUMPED">
  <group id="ContentGroup" label="Content">  
        <button id="textButton" label="Insert Text"  
             screentip="Text" onAction="OnTextButton"  
             supertip="Inserts text at the cursor location."/>  
        <button id="tableButton" label="Insert Table"  
             screentip="Table" onAction="OnTableButton"  
             supertip="Inserts a table at the cursor location."/>  
  </group>  
</tab>