Workbook Access – Is Excel File Opened
Checks whether a specific Excel file is currently open in the given Excel.Application instance.
This function checks if a workbook with the same file name (not full path) is currently open in the given Excel instance by attempting to access it through the Workbooks collection. If access throws an exception, the file is assumed not to be open.
VB
Public Function xlIsExcelFileOpened(CallingApp As Excel.Application,
FileName As String) As Boolean
Try
Dim Wbk As Workbook = CallingApp.Workbooks(Path.GetFileName(FileName))
Wbk = Nothing
Return True
Catch ex As Exception
Return False
End Try
End Function