我正在使用vb.net创建word文档,我有这段代码:
Imports word = Microsoft.Office.Interop.Word
Imports xl = Microsoft.Office.Interop.Excel
Dim oWord As New word.Application
Dim oDoc As word.Document
oWord.Visible = global_variables.ShowWordDocs
但是在运行时,我在最后一行收到此错误:
Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-
0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
最后一行的值等于False
我已经尝试修复Microsoft Office - 我已经安装的是word,excel,office共享功能和办公工具 - 2010版
答案 0 :(得分:0)
错误意味着COM接口存在问题。您是否尝试重新注册(RegSvr32.exe / i ...)用于Word / Excel的COM DLL / TLB / OLB?这些将位于Office安装文件夹中(例如C:\ Program Files \ Microsoft Office \ Office14)