Office 加载项:自定义选项卡不会显示在桌面 PP/Excel,在 365 中工作正常

Office add-in: Custom tab won't show in desktop PP/Excel, works fine in 365

我的清单在 Office 365(Word、Powerpoint、Excel)和桌面版 Word 中测试时运行良好。当 运行 Powerpoint 中的相同清单或桌面上的 Excel 时,自定义选项卡根本不会显示在功能区中。它在底部显示 "Add-ins loaded successfully",但功能区中没有显示选项卡。

这是清单xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
  <Id>130f75aa-a500-458a-bc48-031e57b7d70e</Id>
  <Version>1.1.0.0</Version>
  <ProviderName>MyCompany AB</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="MyCompany Test"/>
  <Description DefaultValue="Sign agreements online with MyCompany"/>
  <IconUrl DefaultValue="https://testbed-office-addin.scrive.com/public/assets/icon-32.png"/>
  <HighResolutionIconUrl DefaultValue="https://testbed-office-addin.scrive.com/public/assets/icon-80.png"/>
  <SupportUrl DefaultValue="https://support.scrive.com/"/>
  <AppDomains>
    <AppDomain>scrive.com</AppDomain>
  </AppDomains>
  <Hosts>
    <Host Name="Workbook"/>
    <Host Name="Document"/>
    <Host Name="Presentation"/>
  </Hosts>
  <DefaultSettings>
    <SourceLocation DefaultValue="https://testbed-office-addin.scrive.com/public"/>
  </DefaultSettings>
  <Permissions>ReadWriteDocument</Permissions>
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Description resid="Version.Description" />
    <Hosts>
      <Host xsi:type="Workbook">
        <DesktopFormFactor>
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <CustomTab id="MyCompanyTab">
              <Group id="MyCompanyCommands">
                <Label resid="CommandsGroup.Label"/>
                <Icon>
                  <bt:Image size="16" resid="Icon.16x16"/>
                  <bt:Image size="32" resid="Icon.32x32"/>
                  <bt:Image size="80" resid="Icon.80x80"/>
                </Icon>
                <Control xsi:type="Button" id="MyCompanyTaskpaneButton">
                  <Label resid="TaskpaneButton.Label"/>
                  <Supertip>
                    <Title resid="TaskpaneButton.Label"/>
                    <Description resid="TaskpaneButton.Tooltip"/>
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16"/>
                    <bt:Image size="32" resid="Icon.32x32"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="Taskpane.Url"/>
                    <Title resid="TaskpaneButton.Label"/>
                  </Action>
                </Control>
              </Group>
              <Label resid="CustomTab.Label"/>
            </CustomTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
      <Host xsi:type="Document">
        <DesktopFormFactor>
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <CustomTab id="MyCompanyTab">
              <Group id="MyCompanyCommands">
                <Label resid="CommandsGroup.Label"/>
                <Icon>
                  <bt:Image size="16" resid="Icon.16x16"/>
                  <bt:Image size="32" resid="Icon.32x32"/>
                  <bt:Image size="80" resid="Icon.80x80"/>
                </Icon>
                <Control xsi:type="Button" id="MyCompanyTaskpaneButton">
                  <Label resid="TaskpaneButton.Label"/>
                  <Supertip>
                    <Title resid="TaskpaneButton.Label"/>
                    <Description resid="TaskpaneButton.Tooltip"/>
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16"/>
                    <bt:Image size="32" resid="Icon.32x32"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="Taskpane.Url"/>
                  </Action>
                </Control>
              </Group>
              <Label resid="CustomTab.Label"/>
            </CustomTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
      <Host xsi:type="Presentation">
        <DesktopFormFactor>
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <CustomTab id="MyCompanyTab">
              <Group id="MyCompanyCommands">
                <Icon>
                  <bt:Image size="16" resid="Icon.16x16"/>
                  <bt:Image size="32" resid="Icon.32x32"/>
                  <bt:Image size="80" resid="Icon.80x80"/>
                </Icon>
                <Control xsi:type="Button" id="MyCompanyTaskpaneButton">
                  <Label resid="TaskpaneButton.Label"/>
                  <Supertip>
                    <Title resid="TaskpaneButton.Label"/>
                    <Description resid="TaskpaneButton.Tooltip"/>
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16"/>
                    <bt:Image size="32" resid="Icon.32x32"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="Taskpane.Url"/>
                  </Action>
                </Control>
                <Label resid="CommandsGroup.Label"/>
              </Group>
              <Label resid="CustomTab.Label"/>
            </CustomTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="Icon.16x16" DefaultValue="https://testbed-office-addin.scrive.com/public/assets/icon-16.png"/>
        <bt:Image id="Icon.32x32" DefaultValue="https://testbed-office-addin.scrive.com/public/assets/icon-32.png"/>
        <bt:Image id="Icon.80x80" DefaultValue="https://testbed-office-addin.scrive.com/public/assets/icon-80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="GetStarted.LearnMoreUrl" DefaultValue="https://www.scrive.com/products/"/>
        <bt:Url id="Taskpane.Url" DefaultValue="https://testbed-office-addin.scrive.com/public/index.html"/>
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="Version.Description" DefaultValue="Sign agreements online with MyCompany"/>
        <bt:String id="GetStarted.Title" DefaultValue="Get started with MyCompany Test!"/>
        <bt:String id="CommandsGroup.Label" DefaultValue="MyCompany"/>
        <bt:String id="CustomTab.Label" DefaultValue="MyCompany Test"/>
        <bt:String id="TaskpaneButton.Label" DefaultValue="MyCompany Test"/>
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="GetStarted.Description" DefaultValue="MyCompany Test loaded successfully. Go to the MyCompany Test tab and click the 'MyCompany Test' button to get started."/>
        <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Click to show MyCompany Test configuration"/>
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>

为了帮助其他为此苦苦挣扎的人,我将 post 我的发现最终使我得到了一个工作清单文件。

  1. Action ShowTaskpane 需要有 <TaskpaneId> 元素
    <Action xsi:type="ShowTaskpane">
      <TaskpaneId>ButtonId1</TaskpaneId>
      <SourceLocation resid="Taskpane.Url"/>
    </Action>
  1. office-addin-debugging 工具有时会在这些位置缓存清单文件 (OSX):
    • /用户//Library/Containers/com.microsoft.Word/Data/Documents/wef
    • /用户//Library/Containers/com.microsoft.Excel/Data/Documents/wef
    • /用户//Library/Containers/com.microsoft.Powerpoint/Data/Documents/wef

这可能会导致在使用调试工具进行测试时,本地所做的更改不会反映出来。在每一轮测试后我开始删除缓存文件后,我很快发现哪些有效,哪些无效。