I've made some code to insert data from an excel table in to an access database - my code is as follow:
Sub AddData()
Dim Cn As ADODB.Connection
Set Cn = New ADODB.Connection
'lets connect to the workbook first, I tested this, it works for me
Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=sample.xls;Extended Properties=Excel 8.0;" _
& "Persist Security Info=False"
' Append data from Sheet1 of workbook to Table1 of mydb.mdb:
Cn.Execute "INSERT INTO tblSales IN 'C:UsersUserDocumentsaccess.mdb' SELECT * FROM [datasheet]"
Cn.Close
Set Cn = Nothing
End Sub
My problem is when executing this I get the error "Microsoft Jet Engine could not find the path to object "datasheet" . Datasheet is just the name of the sheet where the data is located in my workbook. Any help is much appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…