Trying to open excel file from Access - User defined error

forrestgump

Registered User.
Local time
Today, 12:29
Joined
Aug 14, 2017
Messages
10
HI there,

I am trying to open an excel file from MS Access in MS Excel so I can add some vba to remove the top 3 rows of the excel sheet. However, with the code below I keep getting a "User Defined Type Not Defined" error on the first line of the code. How can I stop this so the code will run?

Code:
 Dim xlTmp As Excel.Application
Set xlTmp = New Excel.Application
xlApp.Workbooks.Open "C:\Users\smithj01\Documents\smithltd\FilefromProduction\002_BankDetails_VBATEST.csv"
xlTmp.Visible = True

Any help will be greatly appreciated.

Kind regards,

forrestgump
 
You've the wrong reference, (wrong name):
Code:
Set [B][COLOR=Red]xlTmp[/COLOR][/B] = New Excel.Application [B][COLOR=Red]
xlApp[/COLOR][/B].Workbooks.Open "C:\Users\smithj01\Documents\smithltd\FilefromProduction\002_BankDetails_VBATEST.csv"
 
You're using early binding, which requires the Excel reference be checked in Tools/References.
 

Users who are viewing this thread

Back
Top Bottom