开发者

Office add-in and Ribbon: initialization order?

开发者 https://www.devze.com 2023-03-06 12:00 出处:网络
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 me

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

精彩评论

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

关注公众号