none
Combining App Level Ribbon and Doc Level Ribbon RRS feed

  • Question

  • I am having an issue creating a solution which contains a App Level Ribbon (Designer) w/ the tab named Program which contains a dropdown list for multiple document level projects. Once a document level project is selected I want to add functionality to the Doc Level Ribbon (Designer) Program tab specific to the document that was opened... Is this a feasible solution? Am I setting it up correctly or can it be setup a different way? Is there any articles out there? I get errors or my project doesn't load either tab!

    VSTO 2010

    Tuesday, May 31, 2011 8:38 PM

Answers

  • Thanks for pointing me in the right direction!
    I will just add a little bit of detail here so someone else can benefit from the posting.
    First to help in troubleshooting the AddIns in Word goto Options > Advanced > General > And Check "Show AddIn User Interface Errors" that way when your AddIn loads you can see why it is crashing...
    Second Create your Application Level AddIn Project > Add New Item Ribbon(XML)
    * In here you want to create an xmlns:whatever="AnyNameYouWant"
    * In the tab or group you want to use the idQ as your only id "Do not use id or idMSO"
    * For the value name of the idQ will define the xml namespace provided in the declaration and the unique name of the tab you will be sharing.
     
    Finally Create your Document Level Project and Add the New Ribbon(XML)
    Follow the same steps matching the results for the xmlns: and the idQ...
     
    Application Ribbon XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" xmlns:x="Programming">
     <ribbon>
     <tabs>
      <tab idQ="x:TabProgramming" label="Programming">
      <group id="MyGroup1"
        label="My Group">
      </group>
      </tab>
     </tabs>
     </ribbon>
    </customUI>
    
     
    Document Ribbon XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" xmlns:x="Programming">
     <ribbon>
     <tabs>
      <tab idQ="x:TabProgramming" label="Programming">
      <group id="MyGroup2"
        label="My Group2">
      </group>
      </tab>
     </tabs>
     </ribbon>
    </customUI>
    
     
     NOTE: The "xmlns:x="Programming"" is something I only defined in the XML Files there is no underlying class or namespace i could easily rename to xyz...
     
    Finally for both the ThisDocument.cs and the ThisAddIn.cs overide the CreateRibbonExtensibilityObject() returning a new instance of the Ribbon you created in the project...
     
     protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
     {
      return new AddInRibbon();
     }
    

    Wednesday, June 1, 2011 3:25 PM
  • In order for Ribbons from two different sources to share something (a Tab or a Group) they need to be identified with the same namespace. The namespace has to be declared in the Ribbon XML, with an alias, and then the controls to be shared need to be identified using the attribute idQ. The alias is used in the idQ identification.

    Search for the term idQ in this article to see what I mean: http://msdn.microsoft.com/en-us/library/aa338202(office.12).aspx

    As far as I know, there's no way to do this with the Ribbon Designer. You'd need to export that to Ribbon XML.


    Cindy Meister, VSTO/Word MVP
    Wednesday, June 1, 2011 5:44 AM
    Moderator

All replies

  • In order for Ribbons from two different sources to share something (a Tab or a Group) they need to be identified with the same namespace. The namespace has to be declared in the Ribbon XML, with an alias, and then the controls to be shared need to be identified using the attribute idQ. The alias is used in the idQ identification.

    Search for the term idQ in this article to see what I mean: http://msdn.microsoft.com/en-us/library/aa338202(office.12).aspx

    As far as I know, there's no way to do this with the Ribbon Designer. You'd need to export that to Ribbon XML.


    Cindy Meister, VSTO/Word MVP
    Wednesday, June 1, 2011 5:44 AM
    Moderator
  • Thanks for pointing me in the right direction!
    I will just add a little bit of detail here so someone else can benefit from the posting.
    First to help in troubleshooting the AddIns in Word goto Options > Advanced > General > And Check "Show AddIn User Interface Errors" that way when your AddIn loads you can see why it is crashing...
    Second Create your Application Level AddIn Project > Add New Item Ribbon(XML)
    * In here you want to create an xmlns:whatever="AnyNameYouWant"
    * In the tab or group you want to use the idQ as your only id "Do not use id or idMSO"
    * For the value name of the idQ will define the xml namespace provided in the declaration and the unique name of the tab you will be sharing.
     
    Finally Create your Document Level Project and Add the New Ribbon(XML)
    Follow the same steps matching the results for the xmlns: and the idQ...
     
    Application Ribbon XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" xmlns:x="Programming">
     <ribbon>
     <tabs>
      <tab idQ="x:TabProgramming" label="Programming">
      <group id="MyGroup1"
        label="My Group">
      </group>
      </tab>
     </tabs>
     </ribbon>
    </customUI>
    
     
    Document Ribbon XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" xmlns:x="Programming">
     <ribbon>
     <tabs>
      <tab idQ="x:TabProgramming" label="Programming">
      <group id="MyGroup2"
        label="My Group2">
      </group>
      </tab>
     </tabs>
     </ribbon>
    </customUI>
    
     
     NOTE: The "xmlns:x="Programming"" is something I only defined in the XML Files there is no underlying class or namespace i could easily rename to xyz...
     
    Finally for both the ThisDocument.cs and the ThisAddIn.cs overide the CreateRibbonExtensibilityObject() returning a new instance of the Ribbon you created in the project...
     
     protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
     {
      return new AddInRibbon();
     }
    

    Wednesday, June 1, 2011 3:25 PM
  • Hi Codeitup,

     

    Thank you for sharing your solutions & experience here. It will be very beneficial for other community members who have similar questions!

     

    Also would you like to mark above reply as answer to let us see the solution more clearly?


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, June 3, 2011 7:12 AM
    Moderator