Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Insert data into ACCESS from EXCEL run VBA.

I want to insert data from an Excel range into an ACCESS database and run the procedure from Excel.  After some research, I came across a varition of below but I keep getting an "Automation Error".  But as far can I can tell, the code is correct.  Any suggestions? TESTINGUPLOAD is the name of the range in the Excel workbook.  It gets to the Execute statement and then the error appears.

Private Sub cmdOpenDatabase_Click()
Dim conn As ADODB.Connection
Dim strSQL As String

strSQL = "INSERT INTO tblTESTING SELECT * FROM OPENROWSET([EXCEL 8.0;DATABASE=" & ThisWorkbook.FullName & ";HDR=Yes].[TESTINGUPLOAD]) "

    Set conn = New ADODB.Connection
    conn.Provider = "Microsoft.Jet.OLEDB.4.0;"
    conn.ConnectionString = strDatabaseTestingpath
    conn.Open
    conn.Execute (strSQL)
    conn.Close


End Sub
ASKER CERTIFIED SOLUTION
Avatar of sah18
sah18
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

Both are 2003 versions, but I think i found an alternative in using automation.  So this is moot, I am going to split point however because you both had the grace to respond.
Thanks.