ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SIMPLE ? (https://www.excelbanter.com/excel-programming/298729-simple.html)

Wandering Mage

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

Don Guillett[_4_]

SIMPLE ?
 
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

--
Don Guillett
SalesAid Software

"Wandering Mage" wrote in message
...
Does anyone know how to check within a macro whether a
workbook of name xxxx is currently open. Thanks!




Wandering Mage

SIMPLE ?
 
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?
-----Original Message-----
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

--
Don Guillett
SalesAid Software

"Wandering Mage"

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



.


Bob Phillips[_6_]

SIMPLE ?
 
'-----------------------------------------------------------------
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)

"Wandering Mage" wrote in message
...
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?
-----Original Message-----
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

--
Don Guillett
SalesAid Software

"Wandering Mage"

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



.





All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com