Word 加载项对象始终为空
Word Add-in object always null
我正在尝试使用以下代码获取 iManage Word 加载项对象
using Com.iManage.WorkSiteAddinInterfaces;
public void ManageIManageWordAddIn()
{
iManageExtensibility iManageAddinObj = null;
(COMAddIn addin in Globals.ThisAddIn.Application.COMAddIns)
{
string iManage2007orLater = "WorkSiteOffice2007Addins.Connect"
if (addin.ProgId.Contains(iManage2007orLater))
{
// If addin is connected, try to hijack the DocumentClose2 event
if (addin.Connect)
{
iManageAddinObj = addin.Object as iManageExtensibility; //addin.Object is null
// register to iManageAddinObj events here
iManageAddinObj.DocumentBeforeClose2 += IManageAddinObj_DocumentBeforeClose2;
}
}
}
}
private void IManageAddinObj_DocumentBeforeClose2(object Doc, ref bool IgnoreIManageClose, ref bool Cancel)
{
IgnoreIManageClose = true;
Cancel = true;
}
加载项已连接,但 addin.Object 始终 returns 为空。
COMAddin.Object
属性 不是实现 IDTExtensibility2
等接口的 COM 对象。插件可能会公开它明确想要公开的一些对象。否则为空。
我正在尝试使用以下代码获取 iManage Word 加载项对象
using Com.iManage.WorkSiteAddinInterfaces;
public void ManageIManageWordAddIn()
{
iManageExtensibility iManageAddinObj = null;
(COMAddIn addin in Globals.ThisAddIn.Application.COMAddIns)
{
string iManage2007orLater = "WorkSiteOffice2007Addins.Connect"
if (addin.ProgId.Contains(iManage2007orLater))
{
// If addin is connected, try to hijack the DocumentClose2 event
if (addin.Connect)
{
iManageAddinObj = addin.Object as iManageExtensibility; //addin.Object is null
// register to iManageAddinObj events here
iManageAddinObj.DocumentBeforeClose2 += IManageAddinObj_DocumentBeforeClose2;
}
}
}
}
private void IManageAddinObj_DocumentBeforeClose2(object Doc, ref bool IgnoreIManageClose, ref bool Cancel)
{
IgnoreIManageClose = true;
Cancel = true;
}
加载项已连接,但 addin.Object 始终 returns 为空。
COMAddin.Object
属性 不是实现 IDTExtensibility2
等接口的 COM 对象。插件可能会公开它明确想要公开的一些对象。否则为空。