This documentation is archived and is not being maintained.

RibbonFactory.CreateRibbonManager Method (IRibbonExtension[])

 

Creates an IRibbonExtensibility object that represents a Ribbon customization.

Namespace:   Microsoft.Office.Tools.Ribbon
Assembly:  Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)

IRibbonExtensibility CreateRibbonManager(
	IRibbonExtension[] ribbons
)

Parameters

ribbons
Type: Microsoft.Office.Tools.Ribbon.IRibbonExtension[]

An array of IRibbonExtension instances.

Return Value

Type: Microsoft.Office.Core.IRibbonExtensibility

An object that represents a Ribbon customization.

Return the IRibbonExtensibility object in the CreateRibbonExtensibilityObject method of the ThisAddin, ThisWorkbook, or ThisDocument class of your project to return the Ribbon that you want to display in the Office application.

The following example uses a condition to determine which custom Ribbon to display. This example then uses the CreateRibbonManager method to create and then return an IRibbonExtension object that represents the custom Ribbon.

System_CAPS_noteNote

The syntax used in this example returns a Ribbon that was created by using the Ribbon (Visual Designer) item. The syntax for returning a Ribbon that is created by using a Ribbon (XML) item is slightly different. For more information about returning a Ribbon (XML) item, see Ribbon XML.

    protected override Microsoft.Office.Core.IRibbonExtensibility
CreateRibbonExtensibilityObject()
    {
        if (myCondition == true)
        {
            return Globals.Factory.GetRibbonFactory().CreateRibbonManager(
                new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { new Ribbon1() });
        }
        else
        {
            return Globals.Factory.GetRibbonFactory().CreateRibbonManager(
                new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { new Ribbon2() });
        }
    }
Return to top
Show: