» Determine if a workbook is already open using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Files, Workbook, and Worksheets in VBA
VERSION - All Microsoft Excel Versions
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 Function
Example:
If Not WorkbookOpen("MyWorkbookName.xls") Then
Workbooks.Open "MyWorkbookName.xls"
End If
Book Store:
Recommended Books:
- The McGraw-Hill Guide to Writing a High-Impact Business Plan: A Proven Blueprint for First-Time Entrepreneurs
- Dictionary of Finance and Investment Terms
- Absolute Beginner's Guide to Microsoft Office Excel 2003
- The 22 Immutable Laws of Branding
- What the IRS Doesn't Want You to Know: A Cpa Reveals the Tricks of the Trade
- Infectious Greed: How Deceit and Risk Corrupted the Financial Markets
No comments have been submitted.

