Globals.Ribbons empty on Outlook addin startup?
I'm creating a plugin for Outlook 20开发者_运维百科10 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.
Ribbons created with XML are not accessible using Globals.Ribbons
. See this answer.
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;
}
精彩评论