victorialj
Technical User
Hi there,
I have been trying several methods of checking if a specific spreadsheet is open in excel before continuing to run. However, whichever one I choose, it continually returns false when it is in fact open, and then fails to close that spreadsheet and that instance of Excel.
The function I am using is:
(with Dim xls As Excel.Application and Dim FileName As String declared in the procedure I call the function from).
Does anyone know why this is happening? OR any better suggestions?
Thanks
Victoria
I have been trying several methods of checking if a specific spreadsheet is open in excel before continuing to run. However, whichever one I choose, it continually returns false when it is in fact open, and then fails to close that spreadsheet and that instance of Excel.
The function I am using is:
(with Dim xls As Excel.Application and Dim FileName As String declared in the procedure I call the function from).
Code:
Public Function WorkBookIsOpen(FileName, xls) As Boolean
Dim x As Workbook
With xls
On Error Resume Next
Set x = Workbooks(FileName)
If Err = 0 Then WorkBookIsOpen = True Else WorkBookIsOpen = False
End With
End Function
Does anyone know why this is happening? OR any better suggestions?
Thanks
Victoria