Determine if a workbook is already open
1999-12-20 Workbooks 0 64
The function below can be used to determine if a workbook is open or not:
Function WorkbookOpen(WorkBookName As String) As Boolean ' returns TRUE if the workbook is open WorkbookOpen = False On Error GoTo WorkBookNotOpen If Len(Application.WorkBooks(WorkBookName).Name) > 0 Then WorkbookOpen = True Exit Function End If WorkBookNotOpen: End FunctionExample:
If Not WorkbookOpen("MyWorkbookName.xls") Then Workbooks.Open "MyWorkbookName.xls" End IfYou can use another macro to determine if a workbook is opened by another user or process.