VS 2017 - 尝试打开 Excel 2010 文档以使用 VB.net 进行编辑 - "No such interface supported"
VS 2017 - Trying to Open Excel 2010 document to edit using VB.net - "No such interface supported"
我正在尝试在 VS 2017 上使用 vb.net 编写一个应用程序来打开和编辑 Excel 文档,以便在不同 Windows 版本(7、8、 10 等)和 Microsoft Office 安装(2010、'13 等)。我在 Windows 7 计算机上编写此应用程序,我的办公室版本是 2010。但是,当我 运行 代码时,我收到此错误消息:
Unable to cast COM object of type 'System.__ComObject' to interface
type 'Microsoft.Office.Interop.Excel.Workbooks'. This operation failed
because the QueryInterface call on the COM component for the interface
with IID '{000208DB-0000-0000-C000-000000000046}' failed due to the
following error: No such interface supported (Exception from HRESULT:
0x80004002 (E_NOINTERFACE)).
以下是我的代码:
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Dim GlobalProjectLoc As String
Dim FileLoc As String
Dim excelApp As Excel.Application
Dim excelWB As Excel.Workbooks
Dim excelWS As Excel.Worksheet
Private Sub btnSearch_Click_1(sender As Object, e As EventArgs) Handles btnSearch.Click
GlobalProjectLoc = "C:\Users\Documents\VBA\"
FileLoc = GlobalProjectLoc & "Excel File to Edit"
excelApp = New Excel.Application
excelWB = excelApp.Workbooks.Open(FileLoc)
End Sub
End Class
我已将 Microsoft Office 14.0 Object Library
和 Microsoft Excel 14.0 Object Library
添加到我的参考文献中。我在网上发现了与我的类似的错误消息,但是,当在注册表中搜索错误消息中的 CLSID 时,用户似乎能够通过两次输入版本来找到注册表中的错误。就我而言,当我在注册表中搜索“000208DB-0000-0000-C000-000000000046”时,我没有得到任何结果。
当我安装 VS 2017 时,我安装了以下软件包:通用 Windows 平台开发、.NET 桌面开发和使用 C++ 的桌面开发。我错过了一个重要的吗?
任何帮助将不胜感激,我花了数小时在论坛上进行拖网搜索,试图查看适用于与我有类似问题的人的解决方案是否适用于我的情况,但到目前为止我没有运气.
将 Dim excelWB As Excel.Workbooks
更改为 Dim excelWB As Excel.Workbook
并重试。
我正在尝试在 VS 2017 上使用 vb.net 编写一个应用程序来打开和编辑 Excel 文档,以便在不同 Windows 版本(7、8、 10 等)和 Microsoft Office 安装(2010、'13 等)。我在 Windows 7 计算机上编写此应用程序,我的办公室版本是 2010。但是,当我 运行 代码时,我收到此错误消息:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel.Workbooks'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208DB-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
以下是我的代码:
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Dim GlobalProjectLoc As String
Dim FileLoc As String
Dim excelApp As Excel.Application
Dim excelWB As Excel.Workbooks
Dim excelWS As Excel.Worksheet
Private Sub btnSearch_Click_1(sender As Object, e As EventArgs) Handles btnSearch.Click
GlobalProjectLoc = "C:\Users\Documents\VBA\"
FileLoc = GlobalProjectLoc & "Excel File to Edit"
excelApp = New Excel.Application
excelWB = excelApp.Workbooks.Open(FileLoc)
End Sub
End Class
我已将 Microsoft Office 14.0 Object Library
和 Microsoft Excel 14.0 Object Library
添加到我的参考文献中。我在网上发现了与我的类似的错误消息,但是,当在注册表中搜索错误消息中的 CLSID 时,用户似乎能够通过两次输入版本来找到注册表中的错误。就我而言,当我在注册表中搜索“000208DB-0000-0000-C000-000000000046”时,我没有得到任何结果。
当我安装 VS 2017 时,我安装了以下软件包:通用 Windows 平台开发、.NET 桌面开发和使用 C++ 的桌面开发。我错过了一个重要的吗?
任何帮助将不胜感激,我花了数小时在论坛上进行拖网搜索,试图查看适用于与我有类似问题的人的解决方案是否适用于我的情况,但到目前为止我没有运气.
将 Dim excelWB As Excel.Workbooks
更改为 Dim excelWB As Excel.Workbook
并重试。