How to customize Office 2010 and 2007 Ribbon with your own tabs or controls
In today’s post I’ll demonstrate how you can insert your own ribbon tabs (for Office 2007-2010) and controls (for Office 2000-2003) before or after Office’s built-in tabs or controls. I’ll also show you how you can add an existing built-in Office control to your own ribbon tab.
Each built-in control in Microsoft Office has a unique Id. Ribbon control IDs are strings and command bar control IDs are all integers. Microsoft provides a list of all the built-in Office controls and their IDs; for Office 2007 go here and for Office 2010 use this link. The download contains a whole host of Excel files. Keep them aside for now as we’ll use them later on.
Start off by creating a new Add-in Express COM Add-in project in Visual Studio.
Choose your preferred programming language, for this example I’ll be using C#. Microsoft Office 2007 will be the Minimum supported Office version and Microsoft Word and Outlook will be our Supported Office Applications.
Complete the New Microsoft Office COM Add-in Wizard and add a new ribbon tab component (ADXRibbonTab) to the AddinModule’s designer surface. Design your ribbon tab to look similar to the screenshot below.
This ribbon tab contains all our secret recipes and formulas and we want to make it easy to insert them into our Word documents. Unfortunately you cannot add any custom components to Office’s built-in groups, however, you can create your own custom group and position it amongst the built-in groups.
Let’s place the Secret Research RibbonGroup onto MS Words’ built-in Insert Tab, in between the built-in Text and Symbols Ribbon Groups. In order to accomplish this we first need to see what the Id of the Insert Ribbon tab is. We’re using Office 2007, so open the WordRibbonControls.xlsx that you’ve downloaded earlier. Use Excel’s filters and change the Control Type columns’ filter to only show rows containing the value tab.
Note the control name, in this case its TabInsert and switch back to your project. Change your RibbonTab’s IdMso property to TabInsert. Next, select the Secret Research RibbonGroup and change its InsertBeforeIdMso property to GroupInsertSymbols. You can get the built-in Insert Symbols groups’ ID by filtering the Excel file’s Control Type column on values containing group.
That should do it. Build, register and run your project. If all goes well you should see a new ribbon group between MS Word’s built-in Text and Symbols ribbon groups.
Next, let’s look at something unique to Office 2010, the Backstage View. We’ll add our own menu item to the Outlook Backstage View, and place it in-between the Open and Print menu tabs.
Add a BackstageView component (ADXBackstageView) to the AddinModule designer surface. Add the necessary component to the backstage view to resemble the following image.
In order to have your menu in-between the Help and Options menu items, you need to select the Secret Research Backstage Tab, and change its InsertBeforeIdMso property to TabPrint. Build, register and run your project and you should see the Secret Research tab in-between Print and Open.
As with the ribbon tab, you can also add your own controls in the built-in Office Backstage view tabs. We’ll add our own controls to the Outlook Backstage View’s Help tab next. Add a new ADXBackstageTab and change its layout to resemble the following image:
Change the Help BackstageTab’s IdMso property to TabHelp. To see the ID’s of the Outlook Backstage view, use the OutlookExplorerControls excel file in the download mentioned earlier and filter the Tab Set column on cells containing None (Backstage View). Build, register and run your project and you should see the following in the Outlook Backstage View’s Help tab:
Outlook 2007 is still unique as it utilizes a combination of command and ribbon bars.
Let’s add our own custom command bar button to Outlook 2007’s main toolbar, right in-between the New and Print buttons. To accomplish this add a new ADXOLExplorerCommandBar component to your project’s AddinModule designer surface. Design the commandbar to look like the screenshot below:
Now comes the tricky bit where we have to figure out what Outlook’s built-in command bar’s name is and what its control’s IDs are. Luckily Add-in Express comes to our rescue again with their free Built-in Controls Scanner; with this handy utility we can access the control IDs and names we’re looking for very easy.
As you can see in the above image, the command bar’s name is Standard and the New button’s Office ID is 1874. Make a note of it and switch back to your project in Visual Studio.
Change the ADXOLExplorerCommandBar component’s CommandBarName property to Standard. Set the commanbar button’s AfterId property to 1874. Rebuild, register and run your project. You’ll notice that you now have your own custom button in-between Outlook’s built-in New and Print buttons.
Thank you for reading. Until next time, keep coding!
Available downloads:
This sample add-in was developed using Add-in Express 2010 for Microsoft Office and .net
C# sample Outlook add-in