This documentation is archived and is not being maintained.

How to: Customize the Ribbon

Visual Studio 2005

Note Required applications

The features in this topic are available only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005


    Visual Studio Team System


    Visual Studio 2005 Professional Edition

  • VSTO 2005 SE installed in the development environment

  • 2007 Microsoft Office system

You can create custom tabs and control groups on the Ribbon to integrate your solution into the Microsoft Office user interface (UI). When you add a Ribbon item to your project, Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System (VSTO 2005 SE) generates code and XML that adds a toggle button to the Add-Ins tab by default.


The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, select Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Customizing the Ribbon

To customize the Ribbon

  1. Open or create an application-level project for an application in the 2007 Microsoft Office system. For more information, see How to: Create Visual Studio Tools for Office Projects.


    Microsoft Office Visio 2007 and Microsoft Office InfoPath 2007 do not support customizing the Ribbon. For more information, see Ribbon Extensibility Overview.

  2. On the Project menu, click Add New Item.

  3. In the Add New Item dialog box, select Ribbon.

  4. Change the name of the new Ribbon to MyRibbon, and click Add.

    The MyRibbon.cs or MyRibbon.vb file opens in the designer. An XML file that is named MyRibbon.xml is also added to your project.

  5. In the MyRibbon.cs or MyRibbon.vb file, locate the code comments that start with TODO:, and uncomment the definition of the partial ThisAddIn class. This code enables the Microsoft Office application to discover and load your custom Ribbon UI. For more information, see Ribbon Extensibility Overview.

    After you uncomment the code, it should resemble the following example.

    ' TODO:
    ' This is an override of the RequestService method in ThisAddin class.
    ' To hook up your custom ribbon uncomment this code.
    Partial Public Class ThisAddIn
        Private ribbon As MyRibbon
        Protected Overrides Function RequestService(ByVal serviceGuid As System.Guid) As Object
            If (serviceGuid = GetType(Office.IRibbonExtensibility).GUID) Then
                If ribbon Is Nothing Then
                    ribbon = New MyRibbon()
                End If
                Return ribbon
            End If
            Return MyBase.RequestService(serviceGuid)
        End Function
    End Class
  6. Open the MyRibbon.xml file.

  7. Set the labels of the control group and toggle button in the Ribbon by changing the label attributes of the group and toggleButton elements. By default, the group's label is My Group and the toggle button's label is My Button.

  8. Optionally, you can add more tabs, groups, or controls to the Ribbon by adding XML elements to the MyRibbon.xml file. If you add controls to the Ribbon, you must also define an onAction callback method in the MyRibbon class for each control that you add. For more information, see Walkthrough: Automating an Application from Controls on the Ribbon and Ribbon Extensibility Overview.

See Also