How to assign built-in Office icons to your VSTO Ribbon controls

Miguel OzSenior Software Engineer
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon.

The tool is part of VSTO 2008 Power Tools.  The VSTO 2008 Power Tools can be downloaded from:
The VSTO_PTRibbonIDs.exe installs the Ribbon IDs Tool Window.  After installation, a new "ImageMso Window" item is added on the Tools menu of VS2008 as shown in figure 1.
 VS2008 Tools menuFigure 1. VS2008 Tools menu.

To assign the built-in Office icons to the ribbon button, follow these steps:

1.  On the ribbon designer, select an existing button, or create a new one by dragging it from the toolbox to the ribbon.

2.  On the VS2008 Tools menu, click "ImageMso Window" to display "Image Mso" dialog box.  The dialog box will look like figure 2.
Initial Mso dialog boxFigure 2. Initial Mso dialog box.

3.  In the tool window, type "saveas" in the search box, and click the magnifying glass.  The window will change to show just the related icons (see figure 3) .

VSTO Ribbon IDs Tool WindowFigure 3. VSTO Ribbon IDs Tool Window showing the search results for save.

4.  Any buttons that contains the word "saveas" in the id name will be displayed.  Notice that if you hover over a button, the tool tip shows you the imageMso ID.

5.  Click on the desired image--the tool copies the imageMso ID to the clipboard.

6.  Go to the button property windows and set the value of OfficeImageId by pasting the ID from the clipboard. (See figure 4)

save as button propertiesFigure 4. Ribbon Button property window with the assigned value.

The button now has the specified standard Office icon image.  Notice that you can not see this image at design time--only at run-time.  As an alternative to steps 5 and 6, you can drag-and-drop to copy the imageMso ID from a button to the property windows.  The actual drop target can be text-based source file in Visual Studio (such as your ribbon XML if you're not using the VSTO ribbon designer).

Notice that some Office images have multiple image sizes (32x32, 24x24 and 16x16).  This tool renders all images in either 32x32, or 16x16 format, regardless of the original size of the native image.

For more details you can read the VSTO Power Tools documentation that is part of the download mentioned above.

This tutorial applies to MS Office version 2007 and MS VS2008 (SP1).
Miguel OzSenior Software Engineer

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.