【发布时间】:2019-09-24 20:53:10
【问题描述】:
平台:Office 2019 应用程序:Microsoft Word
我们创建了一个显示在后台视图中的自定义选项卡。
但是,我们希望在后台视图打开时将焦点设置在此选项卡上。该选项卡恰好出现在我们想要的位置并且可以正常工作,但我们希望它被选中。
我的尝试
public void OnShow(object contextObject)
{
try
{
this.ribbon.ActivateTab("OurCustomTab");
}
catch(Exception e )
{
MessageBox.Show(e.ToString());
}
}
上面的代码返回一条消息,说明我提供的值超出范围。
我需要知道的是如何找到自定义选项卡的控件 ID。
自定义 XML
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<commands>
<command idMso="FileSave" onAction="FileSaveOverride"/>
<command idMso="FileSaveAs" onAction="FileSaveAsOverride"/>
</commands>
<backstage onShow="OnShow">
<tab id="OurCustomTab" label="CUSTOM" insertBeforeMso="TabInfo" title="OUR TAB" tag ="OUR" getVisible="IsOURTabVisible" >
<firstColumn>
<group id="OURSave" label="Save" helperText="Performs Save operation for OUR documents">
<primaryItem>
<button id="OurCustomSaveButton" label="Save" imageMso="FileSave" isDefinitive="true" onAction="CustomSaveOverride" />
</primaryItem>
</group>
<group id="OurSaveAs" label="Save As" helperText="Performs Save As operation for OUR documents">
<primaryItem>
<button id="OurCustomSaveAsButton" label="Save As" imageMso="FileSaveAs" isDefinitive="true" onAction="CustomSaveAsOverride" />
</primaryItem>
</group>
</firstColumn>
</tab>
</backstage>
</customUI>
【问题讨论】:
-
看起来答案喜欢在 API“ActivateTab”中。现在找到“ControlId”。我不确定 100% 会在哪里找到它。
标签: ms-word ms-office ribbonx fluent-ribbon