Developer: Overview of the new UI customization model (”RibbonX”)
Archival Notice: This post is no longer current and has been moved to the archive. Please read the new post replacing this one. Images and links in this post are not guaranteed to work.
After highlighting in a previous post the lack of user customization, it is time to look at customization from a developer’s point of view. If you are interested in background reading on the topic or want a look ahead, read the UI blog on developer topics.Office 2007’s Ribbon opens a new chapter for all Office and Windows developers. Except if you have done some Java UI development, you probably will have never encountered the UI programming methodology adopted by Office 2007. Most Office and Windows developers are used to programming the User Interface directly in their code: Whether it is Office, ATL, MFC or .NET’s Windows Forms, a developer always works with an object model that builds or modifies the user interface. For the Ribbon, there is no object model and the UI is not modified/specified with code.
The following SmartArt graphic outlines the process in which the Ribbon UI can be customized:

I admit the graphic looks rather simplistic, but I had trouble with creating a more complex one with graphics. Let me look at each of these steps in detail.

RibbonX code is XML code following an XML Schema provided by Microsoft. According to Wikipedia, “XML is a way of describing data and an XML file can contain the data too”. For the purposes of customizing the Office Ribbon UI, the XML code describes everything. All the information about size, location, visibility, label, ID, etc that developers are accustomed to specifying in code are specified in the RibbonX XML format. If you are totally unfamiliar with XML or its “relative” HTML, take a look at this XML Tutorial. I will showcase the particular syntax of RibbonX in subsequent posts and also show lots of examples.

The Ribbon Application of your choice (Access, Excel, Outlook, PowerPoint or Word) will read your RibbonX code and apply everything you specified in there to its own UI. A big catch with this is that you only get ONE chance to provide your RibbonX code. That means contrary to the usual Office and Windows UI development, the UI you can specify is rather static during the runtime of your add-in. This is a serious limitation compared to add-in development for previous Office versions. Some dynamic functionality is possible though and I will explore these in subsequent posts. When your add-in is unloaded, all the UI modifications you provided via RibbonX will be removed as well. In previous Office versions, a developer had to make sure to remove these things themselves, but Office 2007 takes care of that now.

The last piece in the new customization model is the actual add-in. In the RibbonX code, you specify “callbacks”. Callbacks are functions in your add-in code that Office calls under certain conditions. For example, you can specify a callback that is called by Office when it wants to know whether a particular control is visible or not. You could also specify a callback to have Office get the label for a control. Callbacks are the most important building block for dynamic behavior and adjustment to different localities.
My next posts will show you how to add a “Hello World” button to the first tab of a Ribbon application and show a message box with “Hello World” when you click on it. Each post will focus on different programming languages and situations from which you can do this.


