Function to Check If Workbook is Already Open Using Excel VBA

The following Excel VBA function may be used to test if an Excel workbook is currently open. The wbName parameter refers to the full path of a specific file. The function will return true if the workbook is already open.

Option Explicit

Function IsWbOpen(wbName As String) As Boolean
    On Error Resume Next
    IsWbOpen = Len(Workbooks(wbName).Name)
    On Error GoTo 0
End Function

Leave a Comment