ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Workbook if not already opened (https://www.excelbanter.com/excel-programming/329534-open-workbook-if-not-already-opened.html)

gottahavit

Open Workbook if not already opened
 
I am looking for a procedure that opens a workbook if it is not already open.
How do I find out if a workbook is currently open?

Thanks.

galimi[_2_]

Open Workbook if not already opened
 
The following code should work

Sub isOpen()
On Error GoTo notOpen

Set xlTest = Workbooks("Workbook.xls")
MsgBox "Workbook is open"
Exit Sub

notOpen:
MsgBox "The workbook is NOT open"
Workbooks.Open ("c:\Workbook.xls")

End Sub

Replace the Workbook.xls name with the actual name of your workbook. You'll
also need to specify the path in the Workbooks.Open method in the second to
last line.
--
http://HelpExcel.com
1-888-INGENIO
1-888-464-3646
x0197758


"gottahavit" wrote:

I am looking for a procedure that opens a workbook if it is not already open.
How do I find out if a workbook is currently open?

Thanks.



All times are GMT +1. The time now is 06:14 AM.

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