Private Sub Workbook_Open()
Dim CS As String, Cesta As String, Poz1 As Long, Poz2 As Long
On Error GoTo CHYBA
With ThisWorkbook
Cesta = .Path & "\zdrojová data.xls"
With .Connections("zdrojová data").OLEDBConnection
CS = .Connection
Poz1 = InStr(1, CS, "Source=") + 6
Poz2 = Len(CS) - InStr(Poz1, CS, ";Mode=") + 1
CS = Left$(CS, Poz1) & Cesta & Right$(CS, Poz2)
.Connection = CS
.Refresh
End With
End With
Exit Sub
CHYBA:
MsgBox ("Chyba pri aktualizácii zdrojovej tabuľky :" & vbNewLine & Cesta)
End Subcitovat