VSTO & .NET & Excel

March 11, 2009

Sharing Custom Tabs in The Ribbon UI

Filed under: .NET & Excel, VSTO & Excel — Dennis M Wallentin @ 11:58 pm

To let add-ins (native, unmanaged/managed COM add-ins and VSTO add-ins) share tabs is a good strategy but it can be applied in two different ways. Which to apply is depended on the individual add-ins.

Sharing the Add-ins Tab
For small application it is not necessary to use tabs on their own. Instead we can share the Add-in tab with other add-ins as the first screen shot shows:

tabaddins

 In this case we use the following customized Ribbon XML:

tabaddinsribbonxml

It should be noted that it is not required that any classic CommandBar add-in is activated to access the built-in tab Add-ins. 

Sharing Custom Tabs
For large-scale applications it may be an advantage to split the applications in smaller parts and let the parts share a custom tab. To get there it requires that we:

1. Use a unique identical namespace and 
2. Use a unique identical idQ attribute in the add-ins’ customized Ribbon XML.

A result of this is showed in the following screen shot:

sharedtab

To produce this output we use the following customized Ribbon XML in the add-ins.

The first add-in’s customized Ribbon XML:

 firstcustomizedribbonxml

The second add-in’s customized Ribbon XML:

secondcustomizedribbonxml

As we can see they share the same namespace and call the same idQ attribute which makes it possible to let add-ins share a custom tab.

The customized Ribbon XML for sharing the custom tab is available here.

Kind regards,
Dennis

13 Comments »

  1. Hi Dennis –

    This is very useful information. Is it possible to show the code as text instead of as a screenshot? Alternatively, could you link to a text file?

    Thanks.

    Comment by jonpeltier — March 12, 2009 @ 2:21 pm

    • Jon,
      I have made the Ribbon XML available in a text file which is added to the post.

      As long as I reside on WordPress domain with my blog I cannot use any plugin to handle code with. That’s why I use screen shots.

      Kind regards,
      Dennis

      Comment by Dennis Wallentin — March 12, 2009 @ 8:46 pm

  2. Thanks, Dennis.

    All I use for code on my web site is HTML. I haven’t found a code plugin that doesn’t drive me nuts.

    Comment by jonpeltier — March 13, 2009 @ 3:29 am

    • Jon,

      You’re welcome and thanks for the info about code plugins.

      Kind regards,
      Dennis

      Comment by Dennis Wallentin — March 13, 2009 @ 12:45 pm

  3. Thanks for publishing the tip. Forgetting to define namespace in the root element caught me out for a while.

    Comment by Bill — June 16, 2009 @ 6:21 pm

    • Bill,
      You’re welcome and I also sometimes forget to define namespaces…

      Kind regards,
      Dennis

      Comment by Dennis Wallentin — June 16, 2009 @ 7:10 pm

  4. Hi Dennis… Slightly off topic..
    But over the last month I have struggled to create a Custom Tab for access which will remain visible irrespective of the Database file that I open.
    In excel this is very easy, simply create an add-in, however the same approach does not work for Access…do you know of a work around

    Comment by sam — October 19, 2009 @ 11:15 am

    • sam,

      Unfortunately I’m not the guy to answer anything questions about Access’s UI. If I remember it right Ken Puls’s book on RibbonX deals with it but I’m not 100 % sure.

      Kind regards,
      Dennis

      Comment by Dennis Wallentin — October 19, 2009 @ 11:33 am

  5. Thanks! this was what I needed!

    Comment by Leon — March 18, 2010 @ 10:59 am

  6. Dennis, Thanks very much for this tip.

    The only thing that doesn’t seem to work for me when I use idQ and namespace is the getLabel functionality. I use getLabel along with tag to get the label for different elements of the ribbon. The getLabel works when I don’t use idQ, but doesn’t work when I use idQ.

    Any help would be appreciated.

    Thanks
    Vikram

    Comment by Vikram — June 5, 2011 @ 12:56 pm

    • Vikram,
      Thanks for Your kind words. The getLabel issue is remarkable and I have no ‘out-of-the-box” answer for it.

      At present I’m very busy as I will be moving plus other things. May I suggest that You make a post at the MSDN forum “Excel for Developers Forum”:
      http://social.msdn.microsoft.com/Forums/en-US/exceldev/threads

      Kind regards,
      Dennis

      Comment by Dennis Wallentin — June 5, 2011 @ 7:50 pm

      • Thanks Dennis. I will follow up with a post in MSDN – I’m developing this for Word, hence I will have to post this in the Word fourm.

        Good luck with your move.

        Vikram

        Comment by Vikram — June 6, 2011 @ 9:44 am


RSS feed for comments on this post. TrackBack URI

Leave a reply to jonpeltier Cancel reply

Create a free website or blog at WordPress.com.