Test to see if a workbook is open
I can't find anything in Help on this. When I open workbook "A" I want to
know if workbook "B" is already open because I'll do something in "A" as it opens if that is the case. The other thing I'd really like to know is if you can print from a workbook that is not open. Can anyone help please? |
Test to see if a workbook is open
Reply (from a previouspostin) courtesy of Ron De Bruin:
You can use the workbook open event to run the code http://www.cpearson.com/excel/events.htm Then you can open the workbook like this If bIsBookOpen("test.xls") Then Set destWB = Workbooks("test.xls") Else Set destWB = Workbooks.Open("c:\test.xls") End If Copy this function in a normal module Function bIsBookOpen(ByRef szBookName As String) As Boolean ' Rob Bovey On Error Resume Next bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing) End Function Re printing - I don't believe you can. "Brettjg" wrote: I can't find anything in Help on this. When I open workbook "A" I want to know if workbook "B" is already open because I'll do something in "A" as it opens if that is the case. The other thing I'd really like to know is if you can print from a workbook that is not open. Can anyone help please? |
All times are GMT +1. The time now is 10:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com