SIMPLE ?

W

Wandering Mage

Does anyone know how to check within a macro whether a
workbook of name xxxx is currently open. Thanks!
 
D

Don Guillett

Here is one I use as part of a double_click event from a typed name in a
cell. It activates, if open or opens if not.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
 
W

Wandering Mage

Thanks for the reply. Is there, however, and functions
that just spits out a True/False as to whether or not
given workbook is open?
 
B

Bob Phillips

'-----------------------------------------------------------------
Function IsWbOpen(FileName As String) As Boolean
'-----------------------------------------------------------------
On Error Resume Next
IsWbOpen = CBool(Len(Workbooks(FileName).Name))
End Function


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top