Customizing a Ribbon for Outlook

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

  • Application-level projects

Microsoft Office version

  • Outlook 2007

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

When you customize the Ribbon in Microsoft Office Outlook 2007, you must consider where your custom Ribbon will appear in the application. Outlook does not display the Ribbon in the main application user interface (UI). Instead, Outlook displays the Ribbon in windows that open when users perform certain tasks, such as creating e-mail messages. These application windows are named Inspectors.

link to video For a related video demonstration, see How Do I: Use the Ribbon Designer to Customize the Ribbon in Outlook?.

Assigning a Ribbon to an Inspector

You identify the Inspector you want to customize by specifying the Ribbon type that corresponds to the message class for the Inspector. The steps for specifying the Ribbon type depend on whether you are using the Ribbon Designer or Ribbon XML.

Using the Ribbon Designer

If you are using the Ribbon (Visual Designer) item, click the RibbonType property of the Ribbon in the Properties window, and then select one or more Ribbon IDs from the list of values.

You can add more than one Ribbon to a project. If more than one Ribbon share a Ribbon ID, override the CreateRibbonExtensibilityObject method in the ThisAddin class of your project to specify which Ribbon to display at run time.

For more information, see Ribbon Overview.

For more information about each Ribbon type, see the technical article Customizing the Ribbon in Outlook 2007.

Using Ribbon XML

If you are using the Ribbon (XML) item, check the value of the ribbonID parameter in the Microsoft.Office.Core.IRibbonExtensibility.GetCustomUI method and return the appropriate Ribbon.

The Microsoft.Office.Core.IRibbonExtensibility.GetCustomUI method is automatically generated by Visual Studio Tools for Office in the Ribbon code file. The ribbonID parameter is a string that identifies a specific type of Inspector. For a complete list of the possible values of the ribbonID parameter, see the technical article Customizing the Ribbon in Outlook 2007.

The following code example demonstrates how to display a custom Ribbon only in the Microsoft.Outlook.Mail.Compose Inspector. This is the Inspector that opens when a user creates a new e-mail message. The Ribbon to display is specified in the GetResourceText() method, which is generated in the Ribbon class. For more information about the Ribbon class, see Ribbon XML.

Public Function GetCustomUI(ByVal ribbonID As String) As String _
    Implements Office.IRibbonExtensibility.GetCustomUI

    Dim ribbonXML As String = String.Empty

    If ribbonID = "Microsoft.Outlook.Mail.Compose" Then
        ribbonXML = GetResourceText("Trin_RibbonOutlookBasic.Ribbon1.xml")
    End If 

    Return ribbonXML
End Function
public string GetCustomUI(string ribbonID)
{
    string ribbonXML = String.Empty;

    if (ribbonID == "Microsoft.Outlook.Mail.Compose")
    {
        ribbonXML = GetResourceText("Trin_RibbonOutlookBasic.Ribbon1.xml");
    }

    return ribbonXML;
}

See Also

Concepts

Accessing the Ribbon at Run Time

Ribbon Overview

Ribbon Designer

Ribbon XML