der Code zeigt wie ich mir Exceldateien (Reports) aus dem Intranet ziehe. Mein Problem ist, wenn ich das Makro mehrfach hintereinander ausführe, erhalte ich keine aktuellen Daten, sondern die der ersten Abfrage. Ich vermute das Objekt wird nicht überschrieben.
Ich danke Euch im Voraus
Gruß,
Sebastian
Private Sub GetData(DtVon As Date, DtBis As Date)
800 On Error GoTo GetData_Error
'Build the URL
Dim reportURL$
Dim URL1$, URL2$, URL3$, URL4$, URL5$
Dim s$, i%
'URLx are the fixed parts of the permanent URL.
URL1 = "IntranetLink"
820 URL2 = "&pDatum="
830 URL3 = "&pDatum="
840 URL4 = "pAus=excel"
'===================================================================================== _
_
_
_
' Loop for each Betreieb in the Array:
850 reportURL = URL1 & URL2 & DtVon & URL3 & DtBis & URL4
' Code for Downloading the data from the server:
Dim WinHttpReq As Object, oStream As Object
860 Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
870 WinHttpReq.Open "GET", reportURL, False
880 WinHttpReq.send
890 If WinHttpReq.Status = 200 Then
900 Set oStream = CreateObject("ADODB.Stream")
910 oStream.Open
920 oStream.Type = 1
930 oStream.Write WinHttpReq.responseBody
940 oStream.SaveToFile tmpFilePathLisa, 2 ' 1 = no overwrite, 2 = overwrite
950 oStream.Close
960 End If
970 On Error GoTo 0
980 Exit Sub
GetLisa_Error:
990 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure GetData, line _
_
_
_
" & Erl & "."
End Sub