Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Published on
18,519 Points
1 Endorsement
Last Modified:
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).
Author:Miguel Oz

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Join & Write a Comment

This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month