Expand Minimize

DocumentBase.CreateRibbonObjects Method

Returns an array of OfficeRibbon objects to the CreateRibbonExtensibilityObject method.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

protected virtual IRibbonExtension[] CreateRibbonObjects()

Return Value

Type: Microsoft.Office.Tools.Ribbon.IRibbonExtension[]
An array of OfficeRibbon objects.

This method is called by the default implementation of the CreateRibbonExtensibilityObject method when the project contains Ribbon (Visual Designer) items.

You can also override the CreateRibbonExtensibilityObject method to specify which Ribbons to display at run time. For more information, see Ribbon Overview.

The following code example overrides the CreateRibbonObjects method in the ThisDocument class and returns an array of two OfficeRibbon objects. The example requires that you add two Ribbons to your project called Ribbon1 and Ribbon2 by using the Ribbon (Visual Designer) item. To use this example, run it from the ThisDocument class in a document-level project.

protected override Microsoft.Office.Tools.Ribbon.IRibbonExtension[] CreateRibbonObjects()
{
    Microsoft.Office.Tools.Ribbon.IRibbonExtension[] allRibbons =
        new Microsoft.Office.Tools.Ribbon.IRibbonExtension[2];
    allRibbons[0] = new Ribbon1();
    allRibbons[1] = new Ribbon2();
    return allRibbons;
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft