“By all means let’s be open minded, but not so open minded that our brains drop out.” [Richard Dawkins]

Abstract

How do you check with Excel VBA whether a file is open?

Please read my Disclaimer.

Function IsOpen(sBasename As String) As Boolean
Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks(sBasename)
On Error GoTo 0
IsOpen = Not wb Is Nothing
End Function

This Function only detects open files within the Excel instance it is running. But when a subsequent Open fails, you can return an error and stop - the file was maybe open in another Excel instance or by another network user.

Please read my Disclaimer.

IsOpen.xlsm [14 KB Excel file, open and use at your own risk]