G
Guest
I am setting up code to update data to an Excel spreadsheet through Access.
It works correctly unless the Excel worksheet is already opened. Here is a
sample of the code below issued from Access. Is there a way to test if the
spreadsheet is already opened and if so, issue a message to the user to close
it or close it thorough the program ?
Set xlApp = CreateObject("Excel.Application")
Set wrk = xlApp.Workbooks.Open(Path + file)
Set db = CurrentDb
Set rst = db.OpenRecordset("qryBPSExcel")
rst.MoveFirst
wrk.ActiveSheet.Cells(r, 1) = rst(0)
It works correctly unless the Excel worksheet is already opened. Here is a
sample of the code below issued from Access. Is there a way to test if the
spreadsheet is already opened and if so, issue a message to the user to close
it or close it thorough the program ?
Set xlApp = CreateObject("Excel.Application")
Set wrk = xlApp.Workbooks.Open(Path + file)
Set db = CurrentDb
Set rst = db.OpenRecordset("qryBPSExcel")
rst.MoveFirst
wrk.ActiveSheet.Cells(r, 1) = rst(0)