SIMPLE ?

  • Thread starter Thread starter Wandering Mage
  • Start date Start date
W

Wandering Mage

Does anyone know how to check within a macro whether a
workbook of name xxxx is currently open. Thanks!
 
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
 
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?
 
'-----------------------------------------------------------------
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top