1

I have a ribbon that I need to position after the HomeTab (or any other built-in tab) in Word. But Word seems to ignore the insertAfterMso (and insertBeforeMso) attributes.

I tried using insertAfterQ/insertBeforeQ as well, but I can't get those to work with the built-in tabs.

A snippet of the ribbon XML:

  <customUI 
      onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2006/01/customui"  
      xmlns:cstm1="myns"
      xmlns:cstm2="myns2">
  <ribbon>
    <tabs>
      <tab 
          idQ="cstm1:MyCustomTab" 
          label="My Custom Tab"
          getVisible="MyCustomTab_getVisible"
          insertAfterMso="HomeTab">
    </tabs>
  </ribbon>
</customUI>

I suspect it might be related to the use of the idQ attribute, but I need that feature, so I can't remove it :-/

Note that the tab is displayed on the Office ribbon, but it's at the far right end of the ribbon, as it would be without the insertAfterMso attribute added.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Gertsen
  • 1,078
  • 20
  • 36
  • 1
    You insert the tab after the Home tab. `` See the [documentation](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-customui/141f881c-a5a4-473f-9449-55d3d36579ed) – cybernetic.nomad Dec 02 '21 at 16:05
  • Try to remove the `idQ="cstm1:MyCustomTab"` line of replace it with `id` attribute. – Eugene Astafiev Dec 03 '21 at 12:03

2 Answers2

2

The reason to use the idQ attribute to identify the tab, instead of the regular id attribute, is when more than one VSTO AddIn needs to modify the content of a specific tab.

It turns out that if you want control the position of the tab, by using the insertAfterMso or insertBeforeMso attributes, you need to do so in all AddIns modifying the target tab - adding that attribute to just one of the AddIns is not enough in all situations.

I suspect the same is the case if you are using insertAfterQ and insertBeforeQ.

AddIn loading order can play a role in whether or not you experience this or not.

So my markup was initially correct - but it was being "sabotaged" by my secondary VSTO AddIns.

halfer
  • 19,824
  • 17
  • 99
  • 186
Gertsen
  • 1,078
  • 20
  • 36
-1

There is no such attribute for the customUI element in the ribbon XML. Instead, you need to specify the insertAfterMso attribute for your custom tab element:

<customUI onLoad="Ribbon_Load" 
      xmlns="http://schemas.microsoft.com/office/2006/01/customui"  
      xmlns:cstm1="myns"
      xmlns:cstm2="myns2">
  <ribbon>
    <tabs>
      <tab id="myCustomTab"
           insertAfterMso="HomeTab"
           label="My Custom Tab"
           getVisible="MyCustomTab_getVisible">
    </tabs>
  </ribbon>
</customUI>

By default, if a VSTO 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. See How to: Show Add-in user interface errors.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45