RibbonFactory.CreateRibbonManager(IRibbonExtension[]) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates an IRibbonExtensibility object that represents a Ribbon customization.
public:
Microsoft::Office::Core::IRibbonExtensibility ^ CreateRibbonManager(cli::array <Microsoft::Office::Tools::Ribbon::IRibbonExtension ^> ^ ribbons);
public Microsoft.Office.Core.IRibbonExtensibility CreateRibbonManager (Microsoft.Office.Tools.Ribbon.IRibbonExtension[] ribbons);
abstract member CreateRibbonManager : Microsoft.Office.Tools.Ribbon.IRibbonExtension[] -> Microsoft.Office.Core.IRibbonExtensibility
Public Function CreateRibbonManager (ribbons As IRibbonExtension()) As IRibbonExtensibility
Parameters
- ribbons
- IRibbonExtension[]
An array of IRibbonExtension instances.
Returns
An object that represents a Ribbon customization.
Examples
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
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() });
}
}
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
Remarks
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.