VSTO & .NET & Excel

March 11, 2009

Sharing Custom Tabs in The Ribbon UI

Filed under: .NET & Excel, VSTO & Excel — Dennis 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

8 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


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.