Function BookOpen(Bk As String) As Boolean
Dim T As Excel.workBook
Err.clear 'clears any errors
On Error Resume Next
Set T = Application.Workbooks(Bk)
BookOpen = Not T Is Nothing
Err.clear
On Error GoTo 0
End Function
Sub OpenAWorkbook()
Dim IsOpen As Boolean
Dim BookName As String
BookName = "yourFile.xlsm"
IsOpen = BookOpen(BookName)
If IsOpen Then
MsgBox BookName & " is already open!"
Else
Workbooks.Open (BookName)
End If
End Sub
|