If bIsBookOpen("abc.xls") Then
MsgBox "FOUND " & "abc.xls"
End If
Public Function bIsBookOpen(ByRef szBookName As String) As Boolean
'' Checks to see whether a WorkBook is open.
On Error Resume Next
bIsBookOpen = (Len(Workbooks(szBookName).Name) 0)
End Function
HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------
On 4 Sep 2003 14:00:37 -0700,
(Alan) wrote:
I need to check if a workbook is open but the user may have changed
the path.
The workbook I want to test for is called abc.xls and contains a
specific customised (password-protected) code. I want to test, from
def.xls, if abc.xls is open. The user may have changed the path (and
even the name) of abc.xls, so I can't check is C:\some path\abc.xls is
open.
How do I do this?
The pseudo code might be:
For each open workbook in any instance of Excel
Check for presence of code
If code found then
msgbox "FOUND"
exit for
Next workbook
I am using Excel 2000.
TIA
Alan