Office 加载项和功能区:初始化顺序?

发布于 2024-11-07 11:13:31 字数 53 浏览 4 评论 0原文

加载项和功能区的初始化顺序是什么?加载项对象是否始终在功能区之前创建,或者这可能会有所不同?

What is initialization order of add-in and Ribbon? Is add-in object always created before Ribbon, or this can vary?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬花如无物 2024-11-14 11:13:31

功能区是通过调用插件对象的 RequestService 方法来创建 IRibbonExtensibility 实现的。
因此,该插件必须已经存在。

在功能区 XML 模板中,您可以在功能区 CS 文件中执行以下操作:

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);
    }
}

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);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文