如何解决customtab 和 contextcellmenu :按钮激活/停用
我有一个 Excel Web 插件可以正常工作:
一个包含五个控制按钮的自定义选项卡 一个菜单控件添加到 contextmenucell..
但是激活和取消激活按钮仍然有些困难。
'false' XML 指令引发“无效子元素”消息
解决方法
<OfficeApp ...>
...
<VersionOverrides ...>
...
<Hosts>
<Host ...>
...
<DesktopFormFactor>
<ExtensionPoint ...>
<CustomTab ...>
...
<Group ...>
...
<Control ... id="MyButton">
...
<Action ...>
<Enabled>false</Enabled>
...
</OfficeApp>
,
@RickKirkham`
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xsi:type="TaskPaneApp">
<Id>7F8D6A98-CA41-474C-9DA2-D0A511EC822F</Id>
<Version>1.0.0.0</Version>
<ProviderName>[Provider name]</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="appx" />
<Description DefaultValue="appx description."/>
<!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
<!--<IconUrl DefaultValue="https://appcommandicons.blob.core.windows.net/images/taskpane_32x.png" />-->
<IconUrl DefaultValue="~remoteAppUrl/Images/icone appx.png" />
<Hosts>
<Host Name="Workbook" />
</Hosts>
<Requirements>
<Sets DefaultMinVersion="1.3">
<Set Name="SharedRuntime" MinVersion="1.1"/>
<Set Name="ExcelApi" MinVersion="1.3"/>
<Set Name="DialogApi" MinVersion="1.1"/>
<Set Name ="AddinCommands" MinVersion ="1.1"/>
</Sets>
</Requirements>
<DefaultSettings>
<SourceLocation DefaultValue="~remoteAppUrl/App/Home/Home.html" />
</DefaultSettings>
<Permissions>ReadWriteDocument</Permissions>
<!-- Begin Add-in Commands Mode integration. -->
<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
<!-- Explications languages : https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-owemxml/ef7df550-1528-4efd-b3b8-8b52ad2a8e80-->
<!-- The Hosts node is required. -->
<Hosts>
<!-- Each host can have a different set of commands. -->
<!-- Excel host is Workbook,Word host is Document,and PowerPoint host is Presentation. -->
<!-- Make sure the hosts you override match the hosts declared in the top section of the manifest. -->
<Host xsi:type="Workbook">
<!-- Form factor. Currently only DesktopFormFactor is supported. -->
<DesktopFormFactor>
<!--"This code enables a customizable message to be displayed when the add-in is loaded successfully upon individual install."-->
<GetStarted>
<!--Title of the Getting Started callout. resid points to a ShortString resource -->
<Title resid="Contoso.GetStarted.Title"/>
<!-- Description of the Getting Started callout. resid points to a LongString resource -->
<Description resid="Contoso.GetStarted.Description"/>
<!-- Point to a url resource which details how the add-in should be used. -->
<LearnMoreUrl resid="Contoso.GetStarted.LearnMoreUrl"/>
</GetStarted>
<FunctionFile resid="Contoso.FunctionFile.Url" />
<!-- PrimaryCommandSurface is the main Office Ribbon. -->
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<!-- Use OfficeTab to extend an existing Tab. Use CustomTab to create a new tab. -->
<!---->
<!--<OfficeTab id= "TabHome">-->
<CustomTab id="Contoso.Group1Label">
<!--<Label resid="Contoso.Group1Label"/ >-->
<Group id="Contoso.Group2Label">
<Label resid="Contoso.Group2Label" />
<Icon>
<bt:Image size="16" resid="Contoso.tpicon_16x16" />
<bt:Image size="32" resid="Contoso.tpicon_32x32" />
<bt:Image size="80" resid="Contoso.tpicon_80x80" />
</Icon>
<Control xsi:type="Button" id="residLabel" >
<Label resid="residLabel" />
<Supertip>
<Title resid="Contoso.TaskpaneButton.Label3" />
<Description resid="Contoso.TaskpaneButton.Lancer" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.Ouvrir_16x16" />
<bt:Image size="20" resid="Contoso.Ouvrir_20x20" />
<bt:Image size="24" resid="Contoso.Ouvrir_24x24" />
<bt:Image size="32" resid="Contoso.Ouvrir_32x32" />
<bt:Image size="40" resid="Contoso.Ouvrir_40x40" />
<bt:Image size="80" resid="Contoso.Ouvrir_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action1</FunctionName>
</Action>
</Control>
<Control xsi:type="Button" id="residLabel9" >
<Label resid="residLabel9" />
<Supertip>
<Title resid="Contoso.TaskpaneButton.Label4" />
<Description resid="Contoso.TaskpaneButton.Suspendre" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.Yo$_16x16" />
<bt:Image size="20" resid="Contoso.Yo$_20x20" />
<bt:Image size="24" resid="Contoso.Yo$_24x24" />
<bt:Image size="32" resid="Contoso.Yo$_32x32" />
<bt:Image size="40" resid="Contoso.Yo$_40x40" />
<bt:Image size="80" resid="Contoso.Yo$_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action2</FunctionName>
</Action>
<!--<Enabled>false</Enabled>-->
</Control>
</Group>
<Group id="Contoso.Group3">
<Label resid="Contoso.Group3Label" />
<Icon>
<bt:Image size="16" resid="Contoso.Réinit_16x16" />
<bt:Image size="20" resid="Contoso.Réinit_20x20" />
<bt:Image size="24" resid="Contoso.Réinit_24x24" />
<bt:Image size="32" resid="Contoso.Réinit_32x32" />
<bt:Image size="40" resid="Contoso.Réinit_40x40" />
<bt:Image size="80" resid="Contoso.Réinit_80x80" />
</Icon>
<Control xsi:type="Button" id="residLabel6" >
<Label resid="residLabel6" />
<Supertip>
<Title resid="residLabel6" />
<Description resid="Contoso.TaskpaneButton.Réinit" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.Réinit_16x16" />
<bt:Image size="20" resid="Contoso.Réinit_20x20" />
<bt:Image size="24" resid="Contoso.Réinit_24x24" />
<bt:Image size="32" resid="Contoso.Réinit_32x32" />
<bt:Image size="40" resid="Contoso.Réinit_40x40" />
<bt:Image size="80" resid="Contoso.Réinit_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action3</FunctionName>
</Action>
</Control>
<Control xsi:type="Button" id="residLabel7" >
<Label resid="residLabel7" />
<Supertip>
<Title resid="residLabel7" />
<Description resid="Contoso.TaskpaneButton.Sauver" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.Sauver_16x16" />
<bt:Image size="20" resid="Contoso.Sauver_20x20" />
<bt:Image size="24" resid="Contoso.Sauver_24x24" />
<bt:Image size="32" resid="Contoso.Sauver_32x32" />
<bt:Image size="40" resid="Contoso.Sauver_40x40" />
<bt:Image size="80" resid="Contoso.Sauver_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>actio4</FunctionName>
</Action>
</Control>
</Group>
<Label resid="Contoso.Group1Label" />
</CustomTab>
<!--<InsertAfter>TabReview</InsertAfter>-->
</ExtensionPoint>
<ExtensionPoint xsi:type="ContextMenu">
<OfficeMenu id="ContextMenuCell">
<Control xsi:type="Menu" id="Autre2" >
<Label resid="Contoso.TaskpaneButton.Label2" />
<Supertip>
<Title resid="Contoso.TaskpaneButton.Label2" />
<Description resid="Contoso.TaskpaneButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.No$_16x16" />
<bt:Image size="20" resid="Contoso.No$_20x20" />
<bt:Image size="24" resid="Contoso.No$_24x24" />
<bt:Image size="32" resid="Contoso.No$_32x32" />
<bt:Image size="40" resid="Contoso.No$_40x40" />
<bt:Image size="80" resid="Contoso.No$_80x80" />
</Icon>
<Items>
<Item id="couper">
<Label resid="residLabel5"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.couper_16x16" />
<bt:Image size="20" resid="Contoso.couper_20x20" />
<bt:Image size="24" resid="Contoso.couper_24x24" />
<bt:Image size="32" resid="Contoso.couper_32x32" />
<bt:Image size="40" resid="Contoso.couper_40x40" />
<bt:Image size="80" resid="Contoso.couper_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action5</FunctionName>
</Action>
</Item>
<Item id="copier">
<Label resid="residLabel1"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.Copier_16x16" />
<bt:Image size="20" resid="Contoso.Copier_20x20" />
<bt:Image size="24" resid="Contoso.Copier_24x24" />
<bt:Image size="32" resid="Contoso.Copier_32x32" />
<bt:Image size="40" resid="Contoso.Copier_40x40" />
<bt:Image size="80" resid="Contoso.Copier_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action6</FunctionName>
</Action>
</Item>
<Item id="coller">
<Label resid="residLabel2"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.Coller_16x16" />
<bt:Image size="20" resid="Contoso.Coller_20x20" />
<bt:Image size="24" resid="Contoso.Coller_24x24" />
<bt:Image size="32" resid="Contoso.Coller_32x32" />
<bt:Image size="40" resid="Contoso.Coller_40x40" />
<bt:Image size="80" resid="Contoso.Coller_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action7</FunctionName>
</Action>
</Item>
<Item id="supprimer">
<Label resid="residLabel4"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.Supprimer_16x16" />
<bt:Image size="20" resid="Contoso.Supprimer_20x20" />
<bt:Image size="24" resid="Contoso.Supprimer_24x24" />
<bt:Image size="32" resid="Contoso.Supprimer_32x32" />
<bt:Image size="40" resid="Contoso.Supprimer_40x40" />
<bt:Image size="80" resid="Contoso.Supprimer_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action8</FunctionName>
</Action>
</Item>
</Items>
</Control>
</OfficeMenu>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
</VersionOverrides>
,
您需要将 <Enabled>
标签粘贴到控制元素中:
<Control xsi:type="Button" id="residLabel6" >
<Label resid="residLabel6" />
<Supertip>
<Title resid="residLabel6" />
<Description resid="Contoso.TaskpaneButton.Réinit" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Contoso.Réinit_16x16" />
<bt:Image size="20" resid="Contoso.Réinit_20x20" />
<bt:Image size="24" resid="Contoso.Réinit_24x24" />
<bt:Image size="32" resid="Contoso.Réinit_32x32" />
<bt:Image size="40" resid="Contoso.Réinit_40x40" />
<bt:Image size="80" resid="Contoso.Réinit_80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action3</FunctionName>
</Action>
<Enabled>false</Enabled>
</Control>
默认情况下,Office 应用程序启动时会启用任何加载项命令。如果您希望在 Office 应用程序启动时禁用自定义按钮或菜单项,请在清单中指定。只需在控件声明中的 Enabled
元素正下方(不在内部)添加一个 false
元素(值为 Action
)。
在 Enable and Disable Add-in Commands 文章中阅读更多相关信息。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。