in

MCW Technologies' Community Server

Downloads, blogs, forums, and more

Adventures in Visual Studio Development

Making Visual Studio easier to use, one blog entry at a time

Customizing the Office 12 Ribbon

The Office 12 ribbon groups common tasks into "tabs". Tabs consist of "chunks", which consist of controls. The new model for programmatically customizing the Ribbon is currently called RibbonX and it is a declarative XML format that lives inside a COM AddIn. Unlike the 2003 CommandBar object model, the Ribbon model works exactly the same across each of the Office 12 apps.

The way you customize the Ribbon is by building a Shared AddIn. You then add a Connect class which implements IMsoRibbonExtensibility. The class manages the modifications you want to make to the Ribbon. The IMsoRibbonExtensibility interface has a single function, GetCustomUI, which returns the XML file that contains your modifications. VSTO V3 will have design time support for customizing the Ribbon.

Here is some XML that adds a new tab with 2 chunks:.

<tab id = "New tab" label = "Advanced">
  <chunk id="NewChunk" label="More Stuff">
    <button id="Button1" label="Go Go Go" onAction="DoSomething" />
  </chunk>
</tab>

In the AddIn you would write code similar to the following:

Public Class Connect
  Implements IMsoRibbonExtensibility

  Private ResourceManager = New ResourceManager()

  Public Function GetCustomUI() As String
    Return Resources.GetString("RibbonMods.xml")
  End Function

End Class

I really like this. I like the use of XML. I like the consistency across applications. The only thing I don't like is that by default onAction refers to your VBA code. But that is what VS Tools for Office is for, right?

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add
© Copyright MCW Technologies, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems