Sean W.
Sean W.

Reputation: 863

Excel Context Menu Not Showing

I am using the "Custom UI Editor For Microsoft Office". I have added an "Office 2007 Custom UI Part" which creates the "customui.xml" file for me. It currently has the following code which adds my "Zoom Cell" button to the developer tab.

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">  
  <ribbon>  
    <tabs>  

      <tab idMso="TabDeveloper" >  
        <group id="customGroup1" label="Zoom" insertAfterMso="GroupModify">  

          <button id="customButton1" label="Zoom Cell" size="large" onAction="ZoomCell" imageMso="ZoomPrintPreviewExcel" />

        </group>  
      </tab>  

    </tabs>  
  </ribbon>
</customUI>

What I am trying to do is add the same button basically to the context menu for right-clicking on a cell; however, it is not working for me. If I modify the code even the button from the above code gets removed. Here is what I have tried. I am pretty sure that there is something weird in my xml code; I just can't find it.

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">  
  <ribbon>  
    <tabs>  

      <tab idMso="TabDeveloper" >  
        <group id="customGroup1" label="Zoom" insertAfterMso="GroupModify">  

          <button id="customButton1" label="Zoom Cell" size="large" onAction="ZoomCell" imageMso="ZoomPrintPreviewExcel" />

        </group>  
      </tab>  

    </tabs>  
  </ribbon>
  <contextMenus>
   <contextMenu idMso="ContextMenuCell">
    <button id="MyButton" label="Zoom Cell" onAction="ZoomCell" imageMso="ZoomPrintPreviewExcel" insertBeforeMso="Cut" />
   </contextMenu>
  </contextMenus>
</customUI>

Upvotes: 1

Views: 978

Answers (1)

David Zemens
David Zemens

Reputation: 53663

When I put your code in the CustomUI Editor and try to validate it, I get an error that "contextMenus" is not supported element in the CustomUI namespace, followed by a list of expected/allowable elements:

enter image description here

Allowable elements are:

  • qat
  • officeMenu
  • contextualTabs

It seems from THIS LINK (which is for Outlook, but I believe the approach would be same/similar for Excel/etc.) that context Menus are manipulated through VBA events in Office 2007.

I think that RibbonUI manipulation of context menus was not introduced until 2010.

Upvotes: 1

Related Questions