Detecting if a Window/Workbook is Open
How about something like this
Sub Test()
Dim myWB As Workbook
Dim myString As String
myString = "Book2"
Set myWB = Nothing
On Error Resume Next
Set myWB = Workbooks(myString)
On Error GoTo 0
If Not myWB Is Nothing Then
Debug.Print myString & " is open"
Else
Debug.Print myString & " is not open"
End If
End Sub
HTH,
Barb Reinhardt
"Rob" wrote:
I was wondering how I would have a macro detect whether or not a workbook is
open.
This is what I tried.......
If Application.Windows("Book1.xls") = True Then
Obviously it doesn't work but does someone know what would?
Thanks Much.
R
|