Sub Makro1()
Dim Zosit As String, Cesta As String
Cesta = "D:\Download\"
Zosit = "Príklad KT.xlsx"
On Error Resume Next
Workbooks(Zosit).Activate
If Err.Number <> 0 Then Workbooks.Open Cesta & Zosit
On Error GoTo 0
'práca s daným zošitom ActiveWorkbook
End Sub
Sub Makro2()
Dim WB As Workbook, Zosit As String, Cesta As String
Cesta = "D:\Download\"
Zosit = "Príklad KT.xlsx"
On Error Resume Next
Set WB = Workbooks(Zosit)
On Error GoTo 0
If WB Is Nothing Then Set WB = Workbooks.Open(Cesta & Zosit)
With WB
.Activate 'Activate nieje potrebné na bežné veci. Stačí sa odkazovať na WB alebo použiť with s bodkovou notáciou
'práca s daným zošitom
End With
End Subcitovat