AW: bestimmte Files vom Server auf C: abspeichern
08.05.2009 10:21:00
Tino
Hallo,
versuche es mal so.
Den Bereich wo die Dateinamen stehen bzw. auch Quelle und Ziel muss eventuell angepasst werden.
Option Explicit
Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ( _
ByVal pCaller&, ByVal szURL$, ByVal szFileName$, ByVal dwReserved&, ByVal lpfnCB&) As Long
Public Function DownloadFile(ByVal strURL$, ByVal strLocalFilename$) As Boolean
Dim lngRet As Long
lngRet = URLDownloadToFile(0, strURL, strLocalFilename, 0, 0)
If lngRet = 0 Then DownloadFile = True
End Function
Private Sub Download_Datei_aus_Internet()
Dim strQuell As String, strZiel As String, strInfo As String
Dim Bereich As Range
Dim F As Integer
Set Bereich = Range("A1:A10") 'Bereich anpassen wo die Dateinamen stehen
strQuell = "http:/add/allserver.de/"
'Grund Pfad vom _
Server
strZiel = "C:\Test\" 'wo die Dateien hin sollen
For Each Bereich In Bereich
If Bereich.Value "" Then
If Not DownloadFile(strQuell & Bereich.Text, strZiel & Bereich.Text) Then
strInfo = strInfo & Bereich.Text & vbCrLf
End If
End If
Next Bereich
If strInfo "" Then
strInfo = IIf(Right$(strInfo, 1) = vbCrLf, Left$(strInfo, Len(strInfo) - 1), _
strInfo)
F = FreeFile
Open strZiel & Format(Date, "yyyy-mm-dd") & ".txt" For Output As #F
Print #F, strInfo
Close #F
End If
End Sub
Gruß Tino