加载项和功能区的初始化顺序是什么?加载项对象是否始终在功能区之前创建,或者这可能会有所不同?
答案 0 :(得分:0)
通过调用addin对象的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);
}
}