How to find if a workbook is open
Hi Amir,
This should do it
Function IsWBOpen(Name As String)
Dim oWB As Workbook
On Error Resume Next
Set oWB = Workbooks(Name)
On Error GoTo 0
IsWBOpen = Not (oWB Is Nothing)
End Function
Test with
If IsWBOpen("Stats Manager.xls") Then
Workbooks(Stats Manager.xls").Activate
Else
Workbooks.Open Filename:="Stats Manager.xls"
End If
....
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Amir" wrote in message
...
I want to open a workbook, say "A", to perform some
calculation.However, if the workbook is already open then
I want to activate it and do the calculations. I am a
little bit confused about the code I need to decide
whether it is open or need opening. Can anyone help?
Thanks in advance.
Regards
Amir
|