共用方式為


DocumentBase.CreateRibbonObjects Method

Definition

Returns an array of OfficeRibbon objects to the CreateRibbonExtensibilityObject() method.

protected:
 virtual cli::array <Microsoft::Office::Tools::Ribbon::IRibbonExtension ^> ^ CreateRibbonObjects();
protected virtual Microsoft.Office.Tools.Ribbon.IRibbonExtension[] CreateRibbonObjects ();
abstract member CreateRibbonObjects : unit -> Microsoft.Office.Tools.Ribbon.IRibbonExtension[]
override this.CreateRibbonObjects : unit -> Microsoft.Office.Tools.Ribbon.IRibbonExtension[]
Protected Overridable Function CreateRibbonObjects () As IRibbonExtension()

Returns

An array of OfficeRibbon objects.

Examples

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;
}
Protected Overrides Function CreateRibbonObjects() As  _
Microsoft.Office.Tools.Ribbon.IRibbonExtension()
    Dim allRibbons(1) As Microsoft.Office.Tools.Ribbon.IRibbonExtension
    allRibbons(0) = New Ribbon1
    allRibbons(1) = New Ribbon2
    Return allRibbons
End Function

Remarks

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.

Applies to