Check workbook open or not

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear Sir,

I'm writing a program which will check the workbook open or not. If the workbook isn't opened, open it otherwise do nothing. How can I do this coding ?

Thanks
Eva
 
Eva
One way:
On Error Resume Next
If Len(Workbooks("Misc.xls").Name) = 0 Then
Workbooks.Open Filename:="Your full path goes here\Misc.xls"
Else
Windows("Misc.xls").Activate
End If
On Error GoTo 0

If the workbook is not open then the "Len(.....).Name causes an error, hence
the On Error statement. Also the Length will be zero. Note that there must
be a space after the word "Open". HTH Otto
Eva said:
Dear Sir,

I'm writing a program which will check the workbook open or not. If the
workbook isn't opened, open it otherwise do nothing. How can I do this
coding ?
 
Back
Top