Open a worksheet through OLEDB
Sub openWorksheet()
Dim myConnection As New ADODB.Connection
Dim myRecordset As ADODB.Recordset
myConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Customers.xls;" & _
"Extended Properties=Excel 8.0;"
Set myRecordset = New ADODB.Recordset
myRecordset.Open "customers", myConnection, , , adCmdTable
Do Until myRecordset.EOF
Debug.Print myRecordset("txtCustNumber"), myRecordset("txtBookPurchased")
myRecordset.MoveNext
Loop
End Sub
Related examples in the same category