locked
Add a ribbon group to an existing custom tab? RRS feed

  • Question

  • I have a custom tab I created in an Excel Add-In project that only has one group with a couple of buttons and I want to add a new custom group from a new project. How can I using the Ribbon Designer in VS2010 C#?

    why767

    Tuesday, November 27, 2012 7:34 PM

Answers

  • you can't "share" Ribbon components using the Designer, it can only be done using Ribbon XML.

    The Designer was never intended to provide the full Ribbon XML capability; it was intended as a "crutch" to help those unfamiliar with working with XML (VBA developers) get started with VSTO. Indeed, originally it was not even going to provide the full palette of Ribbon controls. But a survey of potential customers provided enough impetus to at least give us the controls!

    But for more advanced requirements you must use Ribbon XML.


    Cindy Meister, VSTO/Word MVP, my blog

    • Proposed as answer by Quist Zhang Wednesday, November 28, 2012 8:46 AM
    Wednesday, November 28, 2012 7:38 AM
  • Hi Why767,

    As I mentioned in the other thread of yours, your code works fine on my side.

    The below is the screenshot of the effect.

    The only possibility I could think of is that you've forgot to add

    protected override Office.IRibbonExtensibility CreateRibbonExtensibilityObject()
    {
        return new Ribbon1();
    }
    

    in the 2nd addin.

    You can check that and please feel free to let me know if this is not what caused your scenario. 

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 30, 2012 3:09 AM

All replies

  • if by new project you mean - second add-in, then to share ribbon customization between add-ins, both have to have exact same custom xml namespace used in their ribbon customization file.
    Tuesday, November 27, 2012 8:03 PM
  • Yes I mean second add-in. I've dried to change the xml file but can't get it to work. It seems you have to use either the designer or xml. So how can I do that from the designer?

    why767

    Tuesday, November 27, 2012 10:36 PM
  • you can't "share" Ribbon components using the Designer, it can only be done using Ribbon XML.

    The Designer was never intended to provide the full Ribbon XML capability; it was intended as a "crutch" to help those unfamiliar with working with XML (VBA developers) get started with VSTO. Indeed, originally it was not even going to provide the full palette of Ribbon controls. But a survey of potential customers provided enough impetus to at least give us the controls!

    But for more advanced requirements you must use Ribbon XML.


    Cindy Meister, VSTO/Word MVP, my blog

    • Proposed as answer by Quist Zhang Wednesday, November 28, 2012 8:46 AM
    Wednesday, November 28, 2012 7:38 AM
  • Ok I'm still stuck on this. I've tried to create a shared tab in two new projects that I added a Ribbon XML. I can not get the second group to show on the tab. Here's the cod e from the first one and it is loaded first;

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="RibbonLoad"
              xmlns:x="MyNameS">
      <ribbon startFromScratch="false">
        <tabs>
          <tab idQ="x:CustomTab" label="Custom Tab" visible="1">
            <group id="MyGroup1" label="My Group1" visible="1">
              <button id="textButton" label="Insert Text"
                       screentip="Table" onAction="OnTextButton"
                       supertip="Inserts a Table at the cursor location" />
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    
    

    And this is the second one;

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="RibbonLoad"
              xmlns:x="MyNameS">
      <ribbon startFromScratch="false">
        <tabs>
          <tab idQ="x:CustomTab" label="Custom Tab" visible="1">
            <group id="MyGroup2" label="My Group2" visible="1">
              <button id="text2Button" label="Insert Text2" 
                      onAction="OnText2Button"/>
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    
    Thanks everyone for the help.

    why767

    Friday, November 30, 2012 12:48 AM
  • Hi Why767,

    As I mentioned in the other thread of yours, your code works fine on my side.

    The below is the screenshot of the effect.

    The only possibility I could think of is that you've forgot to add

    protected override Office.IRibbonExtensibility CreateRibbonExtensibilityObject()
    {
        return new Ribbon1();
    }
    

    in the 2nd addin.

    You can check that and please feel free to let me know if this is not what caused your scenario. 

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 30, 2012 3:09 AM
  • Yes that was all it was.

    Thanks for your help. :)


    why767

    Friday, November 30, 2012 2:06 PM