Share via


Customizing a Ribbon for Outlook

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

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

Applies to: The information in this topic applies to application-level projects for Outlook 2007 and Outlook 2010. For more information, see Features Available by Office Application and Project Type.

Adding a Custom Ribbon to the Main Application UI

The main application UI in Outlook is called the Explorer. If you are using the Ribbon (Visual Designer) item, you can add a Ribbon to the Explorer by clicking the RibbonType property of the Ribbon in the Properties window, and then selecting Microsoft.Outlook.Explorer.

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.

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.

Specifying the Ribbon Type by Using Ribbon XML

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

The GetCustomUI(String) method is automatically generated by Visual Studio in the Ribbon code file. The ribbonID parameter is a string that identifies the Explorer or 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 Designer

Ribbon XML

Other Resources

Ribbon Overview