Export (0) Print
Expand All
2 out of 9 rated this helpful - Rate this topic

Ribbon Overview

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

  • Application-level projects

Microsoft Office version

  • Excel 2007

  • Word 2007

  • Outlook 2007

  • PowerPoint 2007

For more information, see Features Available by Application and Project Type.

The 2007 Microsoft Office system introduced a user interface (UI) element that is named the Ribbon. You can use Visual Studio Tools for Office to customize the Ribbon of the following applications:

  • Microsoft Office Excel 2007

  • Microsoft Office Outlook 2007

  • Microsoft Office PowerPoint 2007

  • Microsoft Office Word 2007

The Ribbon is a way to organize related commands so that they are easier to find. Commands appear as controls on the Ribbon. Controls are organized into groups along a horizontal strip at the top edge of an application window. Related groups are organized on tabs.

Most of the features that were accessed by using menus and toolbars in earlier versions of the Microsoft Office system can now be accessed by using the Ribbon. For more information, see the technical article Developer Overview of the User Interface for the 2007 Microsoft Office System.

To customize the Ribbon, add one of the following Ribbon items to your Visual Studio Tools for Office project:

  • Ribbon (Visual Designer)

  • Ribbon (XML)

For example, to customize the Excel Ribbon, add a Ribbon item to an Excel add-in project.

Ribbon (Visual Designer) Item

The Ribbon (Visual Designer) item provides advanced tools that make it easier for you to design and develop a custom Ribbon. Use the Ribbon (Visual Designer) item to customize the Ribbon in the following ways:

  • Add custom or built-in tabs to a Ribbon.

  • Add custom groups to a custom or built-in tab.


    A built-in tab or group is one that already exists on the Ribbon of a Microsoft Office application. For example, the Data tab is a built-in tab in Excel. The Connections group is a built-in group on the Data tab.

  • Add custom controls to a custom group.

  • Add custom controls to the Microsoft Office menu.

For more information about how to customize a Ribbon by using the Ribbon (Visual Designer) item, see Ribbon Designer.

Ribbon (XML) Item

Use the Ribbon (XML) item if you want to customize the Ribbon in a way that is not supported by the Ribbon (Visual Designer) item. Use the Ribbon (XML) item to customize the Ribbon in the following ways:

  • Add built-in groups to a custom tab or built-in tab.

  • Add built-in controls to a custom group.

  • Add custom code to override the event handlers of built-in controls.

  • Customize the Quick Access Toolbar.

  • Share a Ribbon customization between add-ins by using a qualified ID.

For more information about how to customize the Ribbon by using the Ribbon (XML) item, see Ribbon XML.

If you create a Ribbon by using the Ribbon Designer, and then decide that you want to customize the Ribbon in ways that the Ribbon (Visual Designer) item does not support, you can export the Ribbon to XML.

Visual Studio Tools for Office automatically creates a Ribbon (XML) item and populates the Ribbon XML file with elements and attributes for each control on the Ribbon.

Not all of the properties that are in the Properties window of the Ribbon designer are transferred to the Ribbon XML file. For example, Visual Studio Tools for Office does not export the value of the Image or Text property. That is because you must create a callback method in the Ribbon code file of the exported project to assign an image or set the text of a control. Visual Studio Tools for Office does not automatically generate callback methods as part of the export process.

In addition, any unchanged default property values do not appear in the resulting Ribbon XML file.

For more information about how to export the Ribbon to XML, see How to: Export a Ribbon from the Ribbon Designer to Ribbon XML.

Updating the Code

A new Ribbon code file is added to Solution Explorer. This file contains the Ribbon XML class. You must create callback methods in the Ribbon Callbacks region of this class to handle user actions, such as clicking a button. Move your code from the event handlers to these callback methods and modify the code to work with the Ribbon extensibility (RibbonX) programming model. For more information, see Ribbon XML.

You must also add code to the ThisAddIn, ThisWorkbook, or ThisDocument class that overrides the CreateRibbonExtensibilityObject method and returns the Ribbon XML class to the Office application.

For more information, see Ribbon XML.

You can add more than one Ribbon item to a single project. This is useful if you want to perform either of the following two tasks:

  • Create Ribbons for Outlook Inspectors.


    An Inspector is a window that opens when users perform certain tasks, such as creating an e-mail message.

  • Select which Ribbon to display at run time.

Creating Ribbons for Outlook Inspectors

Outlook does not display the Ribbon in the main application window. Instead, Outlook displays the Ribbon in an Inspector. You can add a Ribbon for each Inspector to an Outlook add-in project. For more information, see Customizing a Ribbon for Outlook.

Selecting Which Ribbons to Display at Run Time

Because a project can contain more than one Ribbon, you can select which Ribbon to display at run time.

To select a Ribbon to display at run time, override the CreateRibbonExtensibilityObject method in the ThisAddin, ThisWorkbook, or ThisDocument class of your project and return the Ribbon that you want to display. The following example checks the value of a field named myCondition and returns the appropriate Ribbon.


The syntax used in this example returns a Ribbon that was created by using the Ribbon (Visual Designer) item. The syntax for returning a Ribbon that is created by using a Ribbon (XML) item is slightly different. For more information about returning a Ribbon (XML) item, see Ribbon XML.

Protected Overrides Function CreateRibbonExtensibilityObject() As  _
    If myCondition = True Then 
        Return New Microsoft.Office.Tools.Ribbon.RibbonManager _
            (New Microsoft.Office.Tools.Ribbon.OfficeRibbon() _
                 {New Ribbon1()})
        Return New Microsoft.Office.Tools.Ribbon.RibbonManager _
            (New Microsoft.Office.Tools.Ribbon.OfficeRibbon() _
                {New Ribbon2()})
    End If 
End Function
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.