Liebe Leute!
In folgendem Code funktioniert das Entzippen der Datei nicht, wenn ich in der Zeile in den Zeilen nach der "MsgBox LocalFilename" die Variablen "LocalFilename" und "LocalFilePath" verwende, wenn ich aber die Strings (daneben als Text) statt der Variablen einsetzte, funktioniert der Code einwandfrei.
Kann mir jemand sagen, warum das so ist?
Sub PLZ_laden_Österreich()
'Call Einzelschritt
Dim Download_ZIP_File As String
Dim Download_xls_File As String
Dim Url As String
Dim LocalFilename As String
Dim Save_ZIP_File As String
Dim LocalFilePath As String
For i = 1 To 1
Download_ZIP_File = "gemplzstr_" & i & ".zip"
Download_xls_File = "gemplzstr_" & i & ".xls"
'DownloadFile$ = Download_ZIP_File 'here the name with extension
Url = "https://www.statistik.at/verzeichnis/strassenliste/" & Download_ZIP_File 'Here is the web address
If i = 1 Then
Save_ZIP_File = "Burgenland.zip"
End If
LocalFilePath = "V:\Projektverwaltung\Daten"
LocalFilename = LocalFilePath & "\" & Save_ZIP_File 'here the drive and download directory
If URLDownloadToFile(0, Url, LocalFilename, 0, 0) = 0 Then
'Download erfolgreich
'Entzippen
MsgBox LocalFilename
Set oShell = CreateObject("Shell.Application")
Set zipFile = oShell.Namespace(LocalFilename) '("V:\Projektverwaltung\Daten\Burgenland.zip")
If Not zipFile Is Nothing Then
Set targetFolder = oShell.Namespace(LocalFilePath) '("V:\Projektverwaltung\Daten")
If Not targetFolder Is Nothing Then
targetFolder.CopyHere zipFile.Items
Else
MsgBox "Fehler: Zielordner nicht gefunden."
End If
Else
MsgBox "Fehler: Zip-Datei nicht gefunden."
End If
Else
MsgBox "Download fehlgeschlagen!"
Exit Sub
End If
'Überflüssige Dateien löschen
Kill (LocalFilePath & "\" & Download_xls_File)
Next i
End Sub
Danke und schönen Tag
Andi
|