A
Arne Hegefors
Hi! I have a macro that sometimes opens another workbook. However sometimes
that workbook is already open. In that case I do not want to reopen it. I
have a UDF that checks if the workbook in fact is open but the problem is
that I get Error 9. Is there any way to check if the workbook is open and not
get an error? (this error ruins the rest of my program..). strFXOptionPath is
a string that contains the name of the workbook.
If WorkbookIsOpen(strFXOptionPath) = False Then
........
Private Function WorkbookIsOpen(wbname) As Boolean
Dim x As Workbook
On Error Resume Next
Set x = Workbooks(wbname)
If Err = 0 Then WorkbookIsOpen = True _
Else: WorkbookIsOpen = False
End Function
Any help appreciated!
that workbook is already open. In that case I do not want to reopen it. I
have a UDF that checks if the workbook in fact is open but the problem is
that I get Error 9. Is there any way to check if the workbook is open and not
get an error? (this error ruins the rest of my program..). strFXOptionPath is
a string that contains the name of the workbook.
If WorkbookIsOpen(strFXOptionPath) = False Then
........
Private Function WorkbookIsOpen(wbname) As Boolean
Dim x As Workbook
On Error Resume Next
Set x = Workbooks(wbname)
If Err = 0 Then WorkbookIsOpen = True _
Else: WorkbookIsOpen = False
End Function
Any help appreciated!