VB.net(VS2010)读写Excel2010 5
使用VB.net(VS2010)读写出现了以下提示:已经添加了MicrosoftExcel14.0ObjectLibraryUnabletocastCOMobjectof...
使用VB.net(VS2010)读写出现了以下提示:
已经添加了Microsoft Excel 14.0 Object Library
Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: 加载类型库/DLL 时出错。 (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
是什么原因呢? 展开
已经添加了Microsoft Excel 14.0 Object Library
Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: 加载类型库/DLL 时出错。 (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
是什么原因呢? 展开
2个回答
展开全部
你可以使用
Private Sub Form_Load()
Dim a As Object
Dim b As Object
Dim c As Object
Set a = GetObject(, "Excel.Application")
Set b = a.WorkBooks.open(Path & "\工作簿1.xlsx")
a.Visible = False
Set c = b.worksheets(1)
End Sub
要引用:microsoft activex data objects 2.5 library
Private Sub Form_Load()
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
cnn.Open "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=""DSN=Excel Files;DBQ=" & App.Path & "\Book1.xlsx;DriverId=1046;FIL=excel 8.0"""
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "select * from [sheet1$]", cnn
Set Me.MSHFlexGrid1.DataSource = rs
End Sub
追问
VS2010不支持SET语句的
追答
那我就不晓得了, 这个是VB6.0的代码
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询