Home > front end >  VSTO Excel: separate ribbons for different add-ins
VSTO Excel: separate ribbons for different add-ins

Time:11-29

I have two independent VSTO Excel Add-ins projects (Excel 365), each of them create a new Excel ribbon, let's say "Project 1" and "Project 2".

In each project I give unique name to ribbon and also tab on the ribbon.

However, when I install both of these add-ins in excel, the tabs are getting mixed together, and I end up with one ribbon with the mixture of controls from both projects.

How would I create a completely different ribbon for each of the projects?

CodePudding user response:

The idQ property of controls exists to enable multiple add-ins to share containers, such as custom tabs and groups.

In the following example, two add-ins share the same "Sample" group on the add-ins tab; each adds one button to it. The key is specifying the same unique namespace in the <customUI> tag. Then, controls can reference this namespace by using idQ.

First customizations:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" 
  xmlns:x="myNameSpace" >
  <ribbon>
    <tabs>
      <tab idMso="TabAddIns">
        <group idQ="x:Sample" label="Sample">
          <button id="C1" label="Sample Button 1" size="large" 
            imageMso="FileSave" onAction="c_action1" />
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

Second customizations:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" 
  xmlns:x="myNameSpace" >
  <ribbon>
    <tabs>
      <tab idMso="TabAddIns">
        <group idQ="x:Sample" label="Sample">
          <button id="C2" label="Sample Button 2" size="large" 
            imageMso="FileSave" onAction="c_action2" />
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

So, make sure that you use a unique value in each add-in for the idQ attribute.

CodePudding user response:

Make sure the ribbon ids, not just names are different for different addins.

Please include the ribbon XML for both projects.

  • Related