RibbonFactory.CreateRibbonManager(IRibbonExtension[]) 方法

定義

建立 IRibbonExtensibility 物件,代表功能區自訂。Creates an IRibbonExtensibility object that represents a Ribbon customization.

public Microsoft.Office.Core.IRibbonExtensibility CreateRibbonManager (Microsoft.Office.Tools.Ribbon.IRibbonExtension[] ribbons);

參數

ribbons
IRibbonExtension[]

IRibbonExtension 執行個體的陣列。An array of IRibbonExtension instances.

傳回

IRibbonExtensibility

物件,代表功能區自訂。An object that represents a Ribbon customization.

範例

下列範例會使用條件來決定要顯示的自訂功能區。The following example uses a condition to determine which custom Ribbon to display. 然後,此範例會使用 CreateRibbonManager 方法來建立並傳回 IRibbonExtension 代表自訂功能區的物件。This example then uses the CreateRibbonManager method to create and then return an IRibbonExtension object that represents the custom Ribbon.

注意

這個範例中使用的語法會傳回使用 [功能區(視覺化設計工具) ] 專案所建立的功能區。The syntax used in this example returns a Ribbon that was created by using the Ribbon (Visual Designer) item. 傳回使用 [功能區(XML) ] 專案所建立之功能區的語法稍有不同。The syntax for returning a Ribbon that is created by using a Ribbon (XML) item is slightly different. 如需傳回 [功能區(XML) ] 專案的詳細資訊,請參閱功能區 XMLFor 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() });
        }
    }
Protected Overrides Function CreateRibbonExtensibilityObject() As  _
    Microsoft.Office.Core.IRibbonExtensibility
    If myCondition = True Then
        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()})
    End If
End Function

備註

傳回 IRibbonExtensibility CreateRibbonExtensibilityObject 專案之、或類別的方法中的物件, ThisAddin ThisWorkbook ThisDocument 以傳回您想要在 Office 應用程式中顯示的功能區。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.

適用於