Import Specific Cells from Excel to Access (1 Viewer)

evocube

New member
Local time
Yesterday, 23:25
Joined
Nov 6, 2009
Messages
4
I need of a little help on this code. It is suppose to import a specific cell into a specific column of my table. (eventually i want this to go through several excel files, small steps LOL)
Here is my code (using access 2007 going to 2003 excel files)

Sub ADD()
Dim myRec As DAO.Recordset

Dim xl As Excel.Application
Dim xlsht As Excel.Worksheet
Dim xlWrkBk As Excel.Workbook

Set xl = CreateObject("Excel.Application")
Set xlWrkBk = GetObject("C:\Documents and Settings\*******\Desktop\*******.xls")
Set xlsht = xlWrkBk.Worksheets(1)
Set myRec = CurrentDb.OpenRecordset("Customers", dbOpenDynaset)
myRec.AddNew
myRec.Fields("Customer") = xlwrksht.Cells(11, "G")
'myRec.Fields("Test2") = xlwrksht.Cells(9, "E")
'myRec.Fields("Test3") = xlwrksht.Cells(11, "E")
myRec.Update
End Sub

I keep getting error 424 object required on this line:
myRec.Fields("Customer") = xlwrksht.Cells(11, "G")

Thanks!
 

evocube

New member
Local time
Yesterday, 23:25
Joined
Nov 6, 2009
Messages
4
Wow. Dont believe i missed that. Must be the fifth monday this week

Thanks!
 

Brianwarnock

Retired
Local time
Today, 07:25
Joined
Jun 2, 2003
Messages
12,701
LOL, we rerely spot our own syntax/spelling type errors.

Brian
 

Users who are viewing this thread

Top Bottom