or
On Error Resume Next: Err.Clear Windows("Workbook.xls").Activate If Err Then MsgBox "Workbook.xls is not opened ", 64: Exit Sub On Error GoTo 0
or
On Error Resume Next: Err.Clear Windows("Workbook.xls").Activate If Err Then MsgBox "Workbook.xls is not opened ", 64: Exit Sub On Error GoTo 0
And more basic question - May be instead of stopping macro it would be more appropriate to automaticaly open it (especially easy if we know the path).
Using my example (but could be also applied to one presented by nilem:
Sub test() Dim wbk As Workbook, cont As Boolean For Each wbk In Workbooks Debug.Print wbk.Name If LCase(wbk.Name) = "workbook.xls" Then cont = True Exit For End If Next wbk If cont Then Workbooks("Workbook.xls").Activate Else Workbooks.Open "Workbook.xls" 'will become active after opening. if needed info about path shall be added End If End Sub
Best Regards,
Kaper
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks