平台:Office 2019 应用:Microsoft Word
我们创建了一个显示在 Backstage 视图中的自定义选项卡。
但是,我们希望在后台视图打开时将焦点设置在此选项卡上。该选项卡恰好出现在我们想要的位置并且可以正常工作,但我们希望它被选中。
我试过的
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>