开发者

Office add-in and Ribbon: initialization order?

What is initialization order of a开发者_运维百科dd-in and Ribbon? Is add-in object always created before Ribbon, or this can vary?


The ribbon is created by calling the addin object's RequestService method for an IRibbonExtensibility implementation.
Thus, the addin must already exist.

In Ribbon XML templates, you can these this in the Ribbon CS file:

public partial class ThisAddIn {
    private RibbonManager ribbon;
    ///<summary>Returns an object that extends a feature in the 2007 Microsoft Office system.</summary>
    ///<param name="serviceGuid">A System.Guid that identifies an extensibility interface 
    ///that is supported by applications in the 2007 Microsoft Office system.</param>
    ///<returns>An object that implements the extensibility interface that is identified by serviceGuid.</returns>
    protected override object RequestService(Guid serviceGuid) {
        if (!String.IsNullOrEmpty(JournalPath) && serviceGuid == typeof(IRibbonExtensibility).GUID) {
            if (ribbon == null)
                ribbon = new RibbonManager();
            return ribbon;
        }

        return base.RequestService(serviceGuid);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜