Share via


How to: Export a Ribbon from the Ribbon Designer to Ribbon XML

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 Ribbon (Visual Designer) item does not support all possible types of Ribbon customization. To customize the Ribbon in advanced ways, you can export the Ribbon from the designer to Ribbon XML and edit the XML directly.

Note

Not all property values appear in the Ribbon XML file. For more information, see Ribbon Overview.

To export a Ribbon from the Ribbon Designer to Ribbon XML

  1. Right-click the Ribbon code file in Solution Explorer, and then click View Designer.

  2. Right-click the Ribbon Designer, and then click Export Ribbon to XML.

    Visual Studio Tools for Office adds a Ribbon XML file and a Ribbon XML code file to your project.

  3. In the Ribbon code class, locate the comments that start with TODO:.

  4. Copy the code block in these comments to the ThisAddin, ThisWorkbook, or ThisDocument class, depending on which type of solution you are developing.

    This code enables the Microsoft Office application to discover and load your custom Ribbon. For more information, see Ribbon XML.

  5. In the ThisAddin, ThisWorkbook, or ThisDocument class, uncomment the code block.

    After you uncomment the code, it should resemble the following example. In this example, the Ribbon class is called Ribbon1.

    Protected Overrides Function CreateRibbonExtensibilityObject() As  _
    Microsoft.Office.Core.IRibbonExtensibility
        Return New MyRibbon()
    End Function
    
    protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
    {
        return new MyRibbon();
    }
    
  6. Switch to the Ribbon XML code file and find the Ribbon Callbacks region.

    This is where you write callback methods to handle user actions, such as clicking a button.

  7. Create a callback method for each event handler that you wrote in the Ribbon Designer code.

  8. Move all your event handler code from the event handlers to the callback methods, and modify the code to work with the Ribbon extensibility (RibbonX) programming model.

    For information about writing callback methods and using the RibbonX programming model, see Ribbon XML.

See Also

Tasks

Walkthrough: Creating a Custom Tab by Using the Ribbon Designer

Walkthrough: Creating a Custom Tab by Using Ribbon XML

Concepts

Ribbon Overview

Ribbon Designer

Ribbon XML