Home > Blockchain >  Excel Office.js - multiple context menu item control issue
Excel Office.js - multiple context menu item control issue

Time:05-26

I'm working on a new feature for an existing Excel office add-in. This feature requires a new context menu item, however when I add a new item in manifest, only the first menu item shows.

The documentation says you can add "other controls, as needed" - however this is does not work for me.

Code sample below:

 <ExtensionPoint xsi:type="ContextMenu">
  <OfficeMenu id="ContextMenuCell">
    <Control xsi:type="Button" id="Menu1">
      <Label resid="Menu1.Label"/>
      <Supertip>
        <Title resid="Menu1.Label"/>
        <Description resid="Menu1.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="ExecuteFunction">
        <FunctionName>action2</FunctionName>
      </Action>
    </Control>
    <Control xsi:type="Button" id="Menu2">
      <Label resid="Menu2.Label"/>
      <Supertip>
        <Title resid="Menu2.Label"/>
        <Description resid="Menu2.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="ExecuteFunction">
        <FunctionName>action4</FunctionName>
      </Action>
    </Control>
  </OfficeMenu>
</ExtensionPoint>

I have tried this with xsi:type="Menu" and xsi:type="Button" - in both examples the bottom menu item is not shown.

Is this a bug or am I missing something? Thanks.

CodePudding user response:

Hi the ContextMenuCell or ContextMenuText will only allow each add-in to add either a button control or a menu control. You can only add 1 top level menu/button to the Office ContextMenu. At the time it was designed this way so that the Office context menu doesn't get flooded with 3rd party controls. Within your menu, you can only have buttons at the moment.

  • Related