Code Lines of 2003 Access to use in 2007 Access

Ashfaque

Search Beautiful Girls from your town for night
Local time
Today, 15:53
Joined
Sep 6, 2004
Messages
897
Hi,

I recently shifted my db from 2003 to 2007. Thru a module code, I was able to open Excel application with particular file. But the same module doesnt work in Excel 2007.

Any particular reason?

Below were code lines I used in module to open Excel 2003.

Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet

....some code lines....

Set objXL = New Excel.Application
objXL.Visible = True
Set objWkb = objXL.Workbooks.Open("D:\SLS DB\MONTHLYORDERSIN.xls")
Set objSht = objWkb.Worksheets("Sheet1")

....some code lines....

objSht.Columns("A").ColumnWidth = 3

Do I need to make changes in here above...?

Please advise....

Thanks,
Ashfaque
 
Looks right to me.

What kind of misbehaviour are you seeing. Any error message?
 
Thanks Glaxiom for quick attention.

I just changed the extension of Excel file to xlsx and it worked.

Set objWkb = objXL.Workbooks.Open("D:\SLS DB\MONTHLYORDERSIN.xlsx")

Thanks,
Ashfaque
 
Oh...the file was not running again

It produces below error

Run-time erro '9':
Subscript out of range

Set objWkb = objXL.Workbooks.Open("D:\SLS DB\MONTHLYORDERSIN.xlsx")
Set objSht = objWkb.Worksheets("Sheet1")

Any idea?

Thanks,
Ashfaque
 
Do you have a sheet called "Sheet1"?
 
Again thanks Galaxiom,

It was mistakenly renamed. Working... (at least now...)

Thanks,
 

Users who are viewing this thread

Back
Top Bottom