自定义功能区 XML 选项卡未显示在 WORD VSTO 加载项中
Custom Ribbon XML Tab not showing in WORD VSTO Add-In
我按照这个 MSDN Tutorial 创建了一个 WORD 2010
VSTO AddIn 选项卡。我正在使用 VS2015 Community Edition
。当我 运行 Visual Studio 中的应用程序时,它会打开 Word 文档,但 Tab 不会显示在 WORD 中(正如 turorial 的测试步骤所声称的那样)。所以,我无法测试 AddIn。
但是,我可以在 WORD 的 COM 加载项 window 中看到上述加载项已启用 - 如下图所示。另外,当我在下面的过程中放置断点时,我可以看到这个过程被成功调用。 注意:我按照copying/pasting代码、项目名称等逐字按照教程进行。因此,我没有对教程进行任何更改。
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new MyRibbon();
}
更新: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 中的自定义选项卡选项中,我没有看到该选项卡,如下图所示。我应该看哪里?
您的按钮将使用您提供的代码添加到内置 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>
我按照这个 MSDN Tutorial 创建了一个 WORD 2010
VSTO AddIn 选项卡。我正在使用 VS2015 Community Edition
。当我 运行 Visual Studio 中的应用程序时,它会打开 Word 文档,但 Tab 不会显示在 WORD 中(正如 turorial 的测试步骤所声称的那样)。所以,我无法测试 AddIn。
但是,我可以在 WORD 的 COM 加载项 window 中看到上述加载项已启用 - 如下图所示。另外,当我在下面的过程中放置断点时,我可以看到这个过程被成功调用。 注意:我按照copying/pasting代码、项目名称等逐字按照教程进行。因此,我没有对教程进行任何更改。
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new MyRibbon();
}
更新: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 中的自定义选项卡选项中,我没有看到该选项卡,如下图所示。我应该看哪里?
您的按钮将使用您提供的代码添加到内置 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>