我正在尝试使用以下代码获取 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 始终返回 null。