Hello everybody
I try importing data from an excel 2007file to access 2007 using ado and vb6.
the code i m using is :
Sub ADOFromExcelToAccess()' exports data from the active worksheet to a table in an Access database' this procedure must be edited before useDim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long ' connect to the Access database Set cn = New ADODB.Connection cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _ "Data Source=C:\VAS_DB_Test.accdb;" ' open a recordset Set rs = New ADODB.Recordset rs.Open "tbl_Cust", cn, adOpenKeyset, adLockOptimistic, adCmdTable ' all records in a table r = 2 ' the start row in the worksheet Do While Len(Range("A" & r).Formula) > 0 ' repeat until first empty cell in column A With rs .AddNew ' create a new record ' add values to each field in the record .Fields("Numr") = Range("A" & r).Value .Fields("Plz") = Range("B" & r).Value .Fields("Desig") = Range("C" & r).Value .Fields("Norme") = Range("D" & r).Value ' add more fields if necessary... .Update ' stores the new record End With r = r + 1 ' next row Loop rs.Close Set rs = Nothing cn.Close Set cn = NothingEnd Sub
the problem i receive a Runtime Error'1004': Method 'range' Of Object'_global'failed in this line Do While Len(Range("A" & r).Formula) > 0
I was wondering if someone could help me . Other codes will be welcomed (for Access 2007)