how to open excel file in microsoft access 2003?
Hi guys, why i got probelm open an excel file in microsoft access 2003?
please help.
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlWSheet As Excel.Worksheet
Set xlApp = New Excel.Application
xlApp.Workbooks.Open Filename:=Me.txtFilePath.Value
Set xlBook = xlApp.Workbooks
Set xlWSheet = xlBook.Worksheets(1)
when my code run until the open method, it come out error, of "application deined error or object-defined error".
i think Access 10 and Access 11 use different open method.
can anyone help or give a code snippet?
Re: how to open excel file in microsoft access 2003?
I take it that your trying to pass in a Access textbox objects value and not a vb6 one.
VB Code:
xlApp.Workbooks.Open Filename:=Form1!txtFilePath.Value
Also, if your trying to do an import you can use the .TransferSpreadsheet method to do it in one line of code.
Re: how to open excel file in microsoft access 2003?
actually my code is working, it is just that the file corrupted.
:blush: