I am trying to add items to splitbuttons and galleries. The issue is with the Factory. In the following OfficeRibbon code file Factory is unknown. It is also unknown in the addin code file. I am missing a reference somewhere. I have also tried Globals.Factory still unknown.
RibbonButton rc = this.Factory.CreateRibbonButton();
I have the following using statements.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Tools.Ribbon;
//using Microsoft.Office.Tools.Excel.Extensions;
This code also fails in the ThisAddin.cs which has been renamed to ReqCommon.cs in my project.
My desired end goal is to dynamically add items to these two controls. Examples i have found here and elsewhere all seem predicated on this elusive Factory.
The project does reference Microsoft.Office.Tools.Common.v9.0.dll
If you are using the Ribbon Designer - it will automatically create this Factory for you (Globals.Factory.GetRibbonFactory()
) - otherwise you need to create your own Factory by overriding CreateRibbonExtensibilityObject()
in ThisAddin.cs
(your ReqCommon.cs)
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
Ribbon1 tempRibbon = new Ribbon1();
tempRibbon.tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
tempRibbon.tab1.ControlId.OfficeId = "TabHome";
return Globals.Factory.GetRibbonFactory().CreateRibbonManager(new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { tempRibbon });
}
The Ribbon Designer inherits from Ribbon.RibbonBase
which contains the property RibbonBase.Factory
which enables this.Factory
to be used within it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With