Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Excel from Access Prob

Status
Not open for further replies.

TidyTrax

Programmer
Jul 11, 2001
263
AU
I have a database application which opens excel, it then reads the values of a series of cells into vba vars, before putting them into the appropriate table.

To do this i have a form using common dialog control, to browse to the appropriate file, and then off we go.

This all works fine the first time i run the event, but when i try to do it for a second file, it doesnt work.
-----------------------------------------------------
Set objExcelApp = New Excel.Application
Set objExcel = objExcelApp.Workbooks.Open(dbfile)
objExcelApp.Visible = True

For x = start_row To end_row

myVar = sheets("xyz").range("b" & x & "").Value
------------------------------------------------------

This is a snippet of the code it all goes fine the first time, but on trying it for a second file, it doesnt make it past the myVar line. Although if i shut the whole app down and restart it works fine first time but not second, regardless of which file i choose
 
I put in some err handling and the error is

Method "Sheets" of object _Global failed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top