find open workbooks

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

Guest

in a macro I must check if a workbook is open.
Which is the procedure????
 
Hi Costas

Try this

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Sub File_Open_test()
If bIsBookOpen("test.xls") Then
MsgBox "the File is open!"
Else
MsgBox "the File is not open!"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top