Udostępnij za pośrednictwem


Document.CreateRibbonObjects Method (2007 System)

Returns an array of OfficeRibbon objects to the CreateRibbonExtensibilityObject method.

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

Syntax

'Declaration
Protected Overridable Function CreateRibbonObjects As OfficeRibbon()
'Usage
Dim returnValue As OfficeRibbon()

returnValue = Me.CreateRibbonObjects()
protected virtual OfficeRibbon[] CreateRibbonObjects()
protected:
virtual array<OfficeRibbon^>^ CreateRibbonObjects()
protected function CreateRibbonObjects() : OfficeRibbon[]

Return Value

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

Remarks

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

Override this method if you want to specify which Ribbons to display at run time.

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

Examples

The following code example overrides the CreateRibbonObjects method in the ThisAddin or 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.

This example is for a document-level customization.

Protected Overrides Function CreateRibbonObjects() As  _
Microsoft.Office.Tools.Ribbon.OfficeRibbon()
    Dim allRibbons(1) As Microsoft.Office.Tools.Ribbon.OfficeRibbon
    allRibbons(0) = New Ribbon1
    allRibbons(1) = New Ribbon2
    Return allRibbons
End Function
protected override Microsoft.Office.Tools.Ribbon.OfficeRibbon[] 
    CreateRibbonObjects()
{
    Microsoft.Office.Tools.Ribbon.OfficeRibbon[] allRibbons = 
        new Microsoft.Office.Tools.Ribbon.OfficeRibbon[2];            
    allRibbons[0] = new Ribbon1();
    allRibbons[1] = new Ribbon2();
    return allRibbons;
}

.NET Framework Security

See Also

Reference

Document Class

Document Members

Microsoft.Office.Tools.Word Namespace