This topic has not yet been rated - Rate this topic

RibbonFactory.CreateRibbonManager Method

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.

Note Note

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() });
        }
    }


Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ