0

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.

henry434
  • 97
  • 1
  • 9

1 Answers1

2

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.

  • Oh no really? So i am unable to add 2 buttons to the context menu? I will have to add a xsi:Menu and group the 2 buttons inside that? Thats going to be a pain for productivity. Do you know if there are there any plans of enabling multiple context menu items for single add-in? – henry434 May 25 '22 at 11:49
  • Yes, so to be able to add multiple controls, you first need to add one sub-menu to the Context Menu, then add additional buttons inside the menu. I will take note of this pain point for you so it can be added to our backlog. All backlogged items are reviewed and evaluated against other requests. In your situation, I would start with what I suggested first. – Angela - MSFT May 25 '22 at 19:34
  • You can also try to add key tip to your context menu buttons to help speed up a keyboard user if they press the context menu button their keyboard. I believe in the xml manifest, in the label of your control, you can put an ampersand (&) in front of a letter to get the underline to appear under it you want it to have a key tip. (Note it's been years since I've tried the key tip). – Angela - MSFT May 25 '22 at 19:34
  • Good suggestion RE key tip. Will have a play with that. Thanks for the advice. – henry434 May 26 '22 at 11:31
  • @Angela-MSFT Is there any update on having multiple Context Menu(right click)? If not is there an option to enable/disable Sub-Menus items based on the Excel sheet or Cell? For my requirement I cannot allow the user to use some of the Sub-menu items on all the sheets or specific cells(or Range) – WorksOnMyLocal Jun 08 '23 at 14:18
  • @henry434 were you able to find a work around for multiple context menus? Can you please share you findings? – WorksOnMyLocal Jun 08 '23 at 14:29
  • 1
    @WorksOnMyLocal Unfortunately I was unable to find a work around. However, I haven't looked at this since the question was asked, so perhaps Angela-MSFT can give us an update if this is possible now. – henry434 Jun 13 '23 at 13:14
  • @henry434 Ok, Thanks. Looks like It is still not supported by OfficeJS. But have you tried using submenus? Can we enable or disable the submenus within the same contextual menus? – WorksOnMyLocal Jun 13 '23 at 13:28
  • @WorksOnMyLocal I stuck with a single button and moved the additional menu control to the taskpane. I was able to put mutliple buttons inside a menu `menu > +button +button` however I didnt play with enable/disable. I have tried manipulating the manifest via js script but was unable, so it may be the same case here. Worth looking into it though. – henry434 Jun 13 '23 at 13:41
  • Ok, Thanks for the inputs. – WorksOnMyLocal Jun 13 '23 at 14:16