Database 从excel中获取数据并在access中导入
我正在尝试使用vba在记录集中导入一些excel行。 我使用以下连接字符串Database 从excel中获取数据并在access中导入,database,excel,vba,spreadsheet,recordset,Database,Excel,Vba,Spreadsheet,Recordset,我正在尝试使用vba在记录集中导入一些excel行。 我使用以下连接字符串 "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\vmware-host\Shared Folders\Luca\Desktop\barcode ean.xlsx;" & _ "Extended Properties=""Excel 12.0 Xml;HDR=YES;""" 使用ADODB.Command,我使用这个查询来获取数据 Select * from [F
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\vmware-host\Shared Folders\Luca\Desktop\barcode ean.xlsx;" & _
"Extended Properties=""Excel 12.0 Xml;HDR=YES;"""
使用ADODB.Command,我使用这个查询来获取数据
Select * from [Foglio1$]
现在我应该在我的记录集中看到1500行,但它只包含88行
如何获取所有记录???而不是ADODB.Command,而是使用ADODB.Connection进行测试,如下所示:
Sub sofMain20141472Access()
Dim cnn, rst
On Error GoTo ErrHandler
Set cnn = CreateObject("ADODB.Connection")
cnn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0" _
& ";Data Source=\\vmware-host\Shared Folders\Luca\Desktop\barcode ean.xlsx" _
& ";Extended Properties=""Excel 12.0 Xml;HDR=YES"""
cnn.Open
'
Set rst = cnn.Execute("SELECT * FROM [Foglio1$];")
'
' do stuffs on Recordset rst...
'
' ...
'
' close ADO objects:
'
rst.Close
Set rst = Nothing
cnn.Close
Set cnn = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description
Set cnn = Nothing
End Sub