We recommend using Visual Studio 2017

Customizing a Ribbon for InfoPath


When you customize the Ribbon in Microsoft Office InfoPath, you must consider where your custom Ribbon will appear in the application. InfoPath 2010 can display the Ribbon in the following three types of InfoPath application windows:

  • Windows that display a form template that is opened in design mode.

  • Windows that display a form that is based on a form template.

  • The Print Preview window.

Applies to: The information in this topic applies to VSTO Add-in projects for InfoPath 2010. For more information, see Features Available by Office Application and Project Type.

Users and designers open a form template in design mode to modify the appearance and layout of the template. Users open forms that are based in a form template to add content.

The Print Preview window enables designers and users to preview the pages of a form or form template before they print them.

System_CAPS_ICON_note.jpg Note

The AddIns tab does not appear in the Print Preview window. If you want a custom tab to appear in the Print Preview window, make sure that the OfficeId property of the tab is not set to TabAddIns.

You must specify the Ribbon type of each window in which you want your Ribbon to appear.

If you are using the Ribbon (Visual Designer) item, click the RibbonType property of the Ribbon in the Properties window, and then select any of the Ribbon ID's described in the following table.

Ribbon IDWindow in which the Ribbon will appear when you run the project
Microsoft.InfoPath.DesignerWindows that display a form template that is opened in design mode.
Microsoft.InfoPath.EditorWindows that display a form that is based on a form template.
Microsoft.InfoPath.PrintPreviewThe Print Preview window.

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.

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

The M:Microsoft.Office.Core.IRibbonExtensibility.GetCustomUI(System.String) method is automatically generated by Visual Studio in the Ribbon code file. The ribbonID parameter is a string that identifies the type of InfoPath window that is opening.

The following code example demonstrates how to display a custom Ribbon only in a window that displays a form template in design mode. 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 string GetCustomUI(string ribbonID)
            string ribbonXML = String.Empty;

            if (ribbonID == "Microsoft.InfoPath.Designer")
                ribbonXML = GetResourceText("MyInfoPathProject.Ribbon.xml");

            return ribbonXML;

Accessing the Ribbon at Run Time
Ribbon Overview
Ribbon Designer
Ribbon XML