ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find open workbooks (https://www.excelbanter.com/excel-programming/311322-find-open-workbooks.html)

Costas[_2_]

find open workbooks
 
in a macro I must check if a workbook is open.
Which is the procedure????


Ron de Bruin

find open workbooks
 
Hi Costas

Try this

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("test.xls") Then
MsgBox "the File is open!"
Else
MsgBox "the File is not open!"
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Costas" wrote in message ...
in a macro I must check if a workbook is open.
Which is the procedure????





All times are GMT +1. The time now is 11:23 AM.

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