checking if workbook is open

  • Thread starter Thread starter rathika
  • Start date Start date
R

rathika

hi

i have a line workbooks.open("c:\abc.xls")
in my form and some related code.

when the code is called the second time i get the
errormessage the workbook is already open.

so now i want to know is there any function(soemthing
like isopen() ) that tells if a workbook is
already open or not.

thanks

rathika
 
Your problem is not that it is open, it the fact it is being edited.

For example

myExcel.Workbooks.Open ("c:\Myworksheet.xls")
myExcel.Workbooks.Open ("c:\Myworksheet.xls")

runs perfectly, but if I pause the code before the 2nd .Open and edit it in
Excel I get problems.

The second problem is it's Excel that throws the dialog but only the 429
Object error gets reported back to Access.

I would suggest you research firing an Excel macro that can be passed a
filename as a parameter and trap it there. ..
 
You should be able to loop through all of the open workbooks.

Assuming you've got an Excel object instantiated (let's call it objExcel),
then something like the following untested air-code should list each of
them:

For intLoop = 1 To objXL.Application.Workbooks.Count

Debug.Print intLoop & ": " &
objXL.Application.Workbooks(intLoop).Name

Next intLoop

Loop through them all, and see whether you find the one of interest. (To get
the path of the file, refer to objXL.Application.Workbooks(intLoop).Path)
 
Back
Top