Here's a reusable function I use often so I don't have to build code in
every procedure that needs to have a specific file open.
Function bBookIsOpen(wbkName As String) As Boolean
' Checks if a specified workbook is open.
' Arguments: wbkName The name of the workbook
' Returns: True if the workbook is open
Dim X As Workbook
On Error Resume Next
Set X = Workbooks(wbkName)
bBookIsOpen = (Err = 0)
End Function
Example usage...
If Not bBookIsOpen("MyFile.xls") Then
sTemp = "File is not open"
Else
sTemp = "File is open"
End If
MsgBox sTemp
--
Garry
Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc