在Ribbon上的控制图标未能显示为Excel的Office插件,而是显示默认图标。

huangapple go评论66阅读模式
英文:

control icon on ribbon fails to show for Office Addin for Excel instead it shows default icon

问题

我在开发 Office 插件,我已经在自定义选项卡上添加了一个控件,但该控件显示的图标图片与指定的图标不符,而是显示默认图标。

那么,如何才能在功能区中显示为每个控件指定的图标呢?

参考链接: link

以下是显示默认图标的功能区图片:
在Ribbon上的控制图标未能显示为Excel的Office插件,而是显示默认图标。

Manifest.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>81d7e91a-c8e6-454f-806a-9b84cf3e7dd5</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Contoso</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="Add-in"/>
  <Description DefaultValue="A template to get started."/>
  <IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png"/>
  <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-64.png"/>
  <SupportUrl DefaultValue="https://www.contoso.com/help"/>
  <AppDomains>
    <AppDomain>https://www.contoso.com</AppDomain>
  </AppDomains>
  <Hosts>
    <Host Name="Workbook"/>
  </Hosts>
  <DefaultSettings>
    <SourceLocation DefaultValue="https://localhost:3000/taskpane.html"/>
  </DefaultSettings>
  <Permissions>ReadWriteDocument</Permissions>
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Hosts>
      <Host xsi:type="Workbook">
        <DesktopFormFactor>
          <FunctionFile resid="Commands.Url"/>
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <CustomTab id="CustomTab">
              <Label resid="ribbonNameLabel" />
              <Group id="AuthGroup">
                <Label resid="AuthGroupNameLabel" />
                <Icon>
                  <bt:Image size="16" resid="Group1LoginIcon16" />
                  <bt:Image size="32" resid="Group1LoginIcon32" />
                  <bt:Image size="80" resid="Group1LoginIcon80" />
                </Icon>

                <Control xsi:type="Button" id="LoginControl">
                  <Label resid="LoginButtonLabel" />
                  <Supertip>
                    <Title resid="LoginButtonToolTipTitle" />
                    <Description resid="LoginButtonToolTipDescription" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Group1LoginIcon16" />
                    <bt:Image size="32" resid="Group1LoginIcon32" />
                    <bt:Image size="80" resid="Group1LoginIcon80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <TaskpaneId>LoginPanelId</TaskpaneId>
                    <Title resid="LoginTaskPaneTitle" />
                    <SourceLocation resid="LoginTaskPaneUrl" />
                  </Action>
                </Control>
              </Group>
            </CustomTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="Group1LoginIcon16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
        <bt:Image id="Group1LoginIcon32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
        <bt:Image id="Group1LoginIcon80" DefaultValue="https://localhost:3000/assets/icon-64.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html"/>
        <bt:Url id="LoginTaskPaneUrl" DefaultValue="https://localhost:3000/taskpane.html"/>
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="ribbonNameLabel" DefaultValue="Add-in"/>
        <bt:String id="AuthGroupNameLabel" DefaultValue="Auth"/>
        <bt:String id="LoginButtonLabel" DefaultValue="Login" />
        <bt:String id="LoginTaskPaneTitle" DefaultValue="Login" />
        <bt:String id="LoginButtonToolTipTitle" DefaultValue="Tooltip Title" />
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="LoginButtonToolTipDescription" DefaultValue="Tooltip Description" />
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>

环境:
在Ribbon上的控制图标未能显示为Excel的Office插件,而是显示默认图标。

任何帮助将不胜感激。
谢谢

英文:

I am working on office addin where I have added a control on a custom tab. but the control does not show the Icon image specified instead it shows default icon.

So how can we show the icon specified for each control in ribbon ?

Reffered link: link

Following is the ribbon image showing default icon :
在Ribbon上的控制图标未能显示为Excel的Office插件,而是显示默认图标。

Manifest.xml file:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
&lt;OfficeApp xmlns=&quot;http://schemas.microsoft.com/office/appforoffice/1.1&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:bt=&quot;http://schemas.microsoft.com/office/officeappbasictypes/1.0&quot; xmlns:ov=&quot;http://schemas.microsoft.com/office/taskpaneappversionoverrides&quot; xsi:type=&quot;TaskPaneApp&quot;&gt;
&lt;Id&gt;81d7e91a-c8e6-454f-806a-9b84cf3e7dd5&lt;/Id&gt;
&lt;Version&gt;1.0.0.0&lt;/Version&gt;
&lt;ProviderName&gt;Contoso&lt;/ProviderName&gt;
&lt;DefaultLocale&gt;en-US&lt;/DefaultLocale&gt;
&lt;DisplayName DefaultValue=&quot;Add-in&quot;/&gt;
&lt;Description DefaultValue=&quot;A template to get started.&quot;/&gt;
&lt;IconUrl DefaultValue=&quot;https://localhost:3000/assets/icon-32.png&quot;/&gt;
&lt;HighResolutionIconUrl DefaultValue=&quot;https://localhost:3000/assets/icon-64.png&quot;/&gt;
&lt;SupportUrl DefaultValue=&quot;https://www.contoso.com/help&quot;/&gt;
&lt;AppDomains&gt;
&lt;AppDomain&gt;https://www.contoso.com&lt;/AppDomain&gt;
&lt;/AppDomains&gt;
&lt;Hosts&gt;
&lt;Host Name=&quot;Workbook&quot;/&gt;
&lt;/Hosts&gt;
&lt;DefaultSettings&gt;
&lt;SourceLocation DefaultValue=&quot;https://localhost:3000/taskpane.html&quot;/&gt;
&lt;/DefaultSettings&gt;
&lt;Permissions&gt;ReadWriteDocument&lt;/Permissions&gt;
&lt;VersionOverrides xmlns=&quot;http://schemas.microsoft.com/office/taskpaneappversionoverrides&quot; xsi:type=&quot;VersionOverridesV1_0&quot;&gt;
&lt;Hosts&gt;
&lt;Host xsi:type=&quot;Workbook&quot;&gt;
&lt;DesktopFormFactor&gt;
&lt;FunctionFile resid=&quot;Commands.Url&quot;/&gt;
&lt;ExtensionPoint xsi:type=&quot;PrimaryCommandSurface&quot;&gt;
&lt;CustomTab id=&quot;CustomTab&quot;&gt;
&lt;Label resid=&quot;ribbonNameLabel&quot; /&gt;
&lt;Group id=&quot;AuthGroup&quot;&gt;
&lt;Label resid=&quot;AuthGroupNameLabel&quot; /&gt;
&lt;Icon&gt;
&lt;bt:Image size=&quot;16&quot; resid=&quot;Group1LoginIcon16&quot; /&gt;
&lt;bt:Image size=&quot;32&quot; resid=&quot;Group1LoginIcon32&quot; /&gt;
&lt;bt:Image size=&quot;80&quot; resid=&quot;Group1LoginIcon80&quot; /&gt;
&lt;/Icon&gt;
&lt;Control xsi:type=&quot;Button&quot; id=&quot;LoginControl&quot;&gt;
&lt;Label resid=&quot;LoginButtonLabel&quot; /&gt;
&lt;Supertip&gt;
&lt;Title resid=&quot;LoginButtonToolTipTitle&quot; /&gt;
&lt;Description resid=&quot;LoginButtonToolTipDescription&quot; /&gt;
&lt;/Supertip&gt;
&lt;Icon&gt;
&lt;bt:Image size=&quot;16&quot; resid=&quot;Group1LoginIcon16&quot; /&gt;
&lt;bt:Image size=&quot;32&quot; resid=&quot;Group1LoginIcon32&quot; /&gt;
&lt;bt:Image size=&quot;80&quot; resid=&quot;Group1LoginIcon80&quot; /&gt;
&lt;/Icon&gt;
&lt;Action xsi:type=&quot;ShowTaskpane&quot;&gt;
&lt;TaskpaneId&gt;LoginPanelId&lt;/TaskpaneId&gt;
&lt;Title resid=&quot;LoginTaskPaneTitle&quot; /&gt;
&lt;SourceLocation resid=&quot;LoginTaskPaneUrl&quot; /&gt;
&lt;/Action&gt;
&lt;/Control&gt;
&lt;/Group&gt;
&lt;/CustomTab&gt;
&lt;/ExtensionPoint&gt;
&lt;/DesktopFormFactor&gt;
&lt;/Host&gt;
&lt;/Hosts&gt;
&lt;Resources&gt;
&lt;bt:Images&gt;
&lt;bt:Image id=&quot;Group1LoginIcon16&quot; DefaultValue=&quot;https://localhost:3000/assets/icon-16.png&quot;/&gt;
&lt;bt:Image id=&quot;Group1LoginIcon32&quot; DefaultValue=&quot;https://localhost:3000/assets/icon-32.png&quot;/&gt;
&lt;bt:Image id=&quot;Group1LoginIcon80&quot; DefaultValue=&quot;https://localhost:3000/assets/icon-64.png&quot;/&gt;
&lt;/bt:Images&gt;
&lt;bt:Urls&gt;
&lt;bt:Url id=&quot;Commands.Url&quot; DefaultValue=&quot;https://localhost:3000/commands.html&quot;/&gt;
&lt;bt:Url id=&quot;LoginTaskPaneUrl&quot; DefaultValue=&quot;https://localhost:3000/taskpane.html&quot;/&gt;
&lt;/bt:Urls&gt;
&lt;bt:ShortStrings&gt;
&lt;bt:String id=&quot;ribbonNameLabel&quot; DefaultValue=&quot;Add-in&quot;/&gt;
&lt;bt:String id=&quot;AuthGroupNameLabel&quot; DefaultValue=&quot;Auth&quot;/&gt;
&lt;bt:String id=&quot;LoginButtonLabel&quot; DefaultValue=&quot;Login&quot; /&gt;
&lt;bt:String id=&quot;LoginTaskPaneTitle&quot; DefaultValue=&quot;Login&quot; /&gt;
&lt;bt:String id=&quot;LoginButtonToolTipTitle&quot; DefaultValue=&quot;Tooltip Title&quot; /&gt;
&lt;/bt:ShortStrings&gt;
&lt;bt:LongStrings&gt;
&lt;bt:String id=&quot;LoginButtonToolTipDescription&quot; DefaultValue=&quot;Tooltip Description&quot; /&gt;
&lt;/bt:LongStrings&gt;
&lt;/Resources&gt;
&lt;/VersionOverrides&gt;
&lt;/OfficeApp&gt;

Environment:
在Ribbon上的控制图标未能显示为Excel的Office插件,而是显示默认图标。

Any help will be appreciated.
Thanks

答案1

得分: 1

首先,请确保通过导航到清单中指定的URL来访问所有图标。如果您看不到图标,请使其可访问。

其次,请确保在Excel中没有显示任何功能区UI错误。默认情况下,如果插件尝试操纵Microsoft Office用户界面(UI)并失败,将不会显示错误消息。但是,您可以配置Microsoft Office应用程序以显示与UI相关的错误消息。您可以使用这些消息来帮助确定自定义功能区未显示的原因,或者为什么功能区显示但没有控件显示。

  1. 启动应用程序。
  2. 单击“文件”选项卡。
  3. 单击“选项”。
  4. 在类别窗格中,单击“高级”。
  5. 在详细信息窗格中,选择“显示VSTO插件用户界面错误”,然后单击“确定”。

第三,如果您的新图像未显示,请尝试清除Office缓存

英文:

First of all, make sure that all icons are accessible by navigating to the URL specified in the manifest. If you don't see the icon then make it accessible.

Second, make sure no ribbon UI errors are shown in Excel. By default, if an add-in attempts to manipulate the Microsoft Office user interface (UI) and fails, no error message is displayed. However, you can configure Microsoft Office applications to display messages for errors that relate to the UI. You can use these messages to help determine why a custom ribbon does not appear, or why a ribbon appears but no controls appear.

  1. Start the application.
  2. Click the File tab.
  3. Click Options.
  4. In the categories pane, click Advanced.
  5. In the details pane, select Show VSTO Add-in user interface errors, and then click OK.

Third, try to Clear the Office cache if your new images are not displayed.

huangapple
  • 本文由 发表于 2023年2月8日 20:40:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75385936.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定