customtab 和 contextcellmenu :按钮激活/停用

如何解决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 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-