0

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

4

1 回答 1

0

COMAddin.Object属性不是实现IDTExtensibility2etc 接口的 COM 对象。插件可能会公开一些它明确想要公开的对象。如果不是,它将为空。

于 2021-07-07T16:19:20.457 回答