Print excel Doc. in Access

deanwat

New member
Local time
Today, 06:09
Joined
Nov 14, 2007
Messages
5
I am trying to to print the data from an excel document to the immediate window in access. the excel file is My Customers.xls. and this is what code I have so far. It runs but nothing appears to happen.

Code:
Sub openWorksheet()
    Dim con1 As New ADODB.Connection
    Dim rec1 As ADODB.Recordset
    
    con1.Open "Provider=Microsoft.jet.OLEDB.4.0;" & _
        "Data Source=C:\Documents and Settings\Dean\Desktop\MyCustomers.xls;" & _
        "Extended Properties=Excel 8.0;"
        
        Set rec1 = New ADODB.Recordset
        rec1.Open "Customers", con1, , , adCmdTable
        
        Do Until rec1.EOF
            Debug.Print rec1("txtCustNumber"), rec1("txtBookPurchased")
            rec1.MoveNext
        Loop
        
End Sub
 

Users who are viewing this thread

Back
Top Bottom