Unable to cast COM object of type 'System.__ComObject' to interface type 'YJWordAddIn.IAddinUtilities'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{8D66A10E-47F2-33CA-B987-64DB9ECA6B1F}' failed due to the following error: 不支持此接口 (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
调用代码:
object addinName = "WordAddIn";
Microsoft.Office.Core.COMAddIn addin = m_word.COMAddIns.Item(ref addinName);
if (addin.Connect)
{
WordAddIn.IAddinUtilities utils = null;
while (utils == null)
{
utils = (WordAddIn.IAddinUtilities)addin.Object;//此处报错
System.Threading.Thread.Sleep(100);
}
m_word.Visible = true;
m_word.Activate();//激活MSWord.Application 使其置顶
utils.CheckDocument(“2017”, “2017”,0,"");
}