3

I'm creating a plugin for Outlook 2010 using VSTO 2010 and .NET 4. I am using the XML method to design my ribbon because I need the context-menu hooks. Unfortunately, though the ribbon is created before the Startup event handler of the addin is fired, I can't access the ribbon using Globals.Ribbons.MyRibbon in the handler! I have added the following in my Ribbon.cs code:

partial class ThisRibbonCollection : Microsoft.Office.Tools.Ribbon.RibbonReadOnlyCollection
{
  internal MyRibbon MyRibbon
  {
    get { return this.GetRibbon<MyRibbon>(); }
  }
}

But it seems that the RibbonReadOnlyCollection is empty when I try to access it from the startup event handler.

On the other hand, if I use the designer, I can access the collection with no problem. How do I add my new ribbon into the collection? I don't see any set methods or any instance of the ribbon collection that's tweakable.

Mike Caron
  • 5,674
  • 4
  • 48
  • 71

2 Answers2

1

Ribbons created with XML are not accessible using Globals.Ribbons. See this answer.

Community
  • 1
  • 1
Marco Ferrari
  • 4,914
  • 5
  • 33
  • 53
0

ThisAddIn

public Ribbon myRibbon;
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
            {
                Ribbon appointmentRibbon = new Ribbon();
                myRibbon = appointmentRibbon;  // save to local variable

                IRibbonExtensibility ribbonExtensibility = appointmentRibbon;
                return ribbonExtensibility;
            }
kavun
  • 3,358
  • 3
  • 25
  • 45
SamFlushing
  • 97
  • 1
  • 7