Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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.
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.