Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have some code that I do NOT want to execute if Workbook "Stats
Manager.xls" is open. What is the code to check to see if "Stats Manager.xls" is open? Thank you Todd Huttenstine |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Todd,
You can use the following function proc. Function IsWorkbookOpen(WBName As String) As Boolean On Error Resume Next IsWorkbookOpen = CBool(Len(Workbooks(WBName).Name)) End Function Then, you can call it from code with a statement like If IsWorkbookOpen(WBName:="Stats Manager.xls") = True Then ' do you thing End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Todd Huttenstine" wrote in message ... I have some code that I do NOT want to execute if Workbook "Stats Manager.xls" is open. What is the code to check to see if "Stats Manager.xls" is open? Thank you Todd Huttenstine |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Todd
Try this example that is using a function Function bIsBookOpen(ByRef szBookName As String) As Boolean ' Rob Bovey On Error Resume Next bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing) End Function Sub File_Open_test() If bIsBookOpen("Book11.xls") Then MsgBox "the File is open!" Else MsgBox "the File is not open!" End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Todd Huttenstine" wrote in message ... I have some code that I do NOT want to execute if Workbook "Stats Manager.xls" is open. What is the code to check to see if "Stats Manager.xls" is open? Thank you Todd Huttenstine |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Todd,
Here's a simple little function that checks for a workbook being open Function IsWBOpen(Name As String) Dim oWB As Workbook On Error Resume Next Set oWB = Workbooks(Name) On Error GoTo 0 IsWBOpen = Not (oWB Is Nothing) End Function Test with If IsWBOpen("Stats Manager.xls") Then .... -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Todd Huttenstine" wrote in message ... I have some code that I do NOT want to execute if Workbook "Stats Manager.xls" is open. What is the code to check to see if "Stats Manager.xls" is open? Thank you Todd Huttenstine |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanx
"Todd Huttenstine" wrote in message ... I have some code that I do NOT want to execute if Workbook "Stats Manager.xls" is open. What is the code to check to see if "Stats Manager.xls" is open? Thank you Todd Huttenstine |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
RETRIEVE DATA FROM ANOTHER WORKBOOK BY CHECKING ON WORKBOOK DATE | Excel Worksheet Functions | |||
Checking if workbook is open | Excel Programming | |||
Checking if workbook open (where path is unknown) | Excel Programming | |||
Checking for Open Workbook | Excel Programming | |||
checking if workbook is open before accessing | Excel Programming |