Telecharger un fichier .tar depuis une page WEB en VBA
Bonjour,
S'il vous plait j'aurai besoin de votre aide pour télécharger ce fichier . tar automatiquement
Code:
<a href=" d92519280.02.a00.tar?B&csrfToken="><img src="/icons/archive.gif" border="0">d92519280.02.a00.tar</a>
j'ai essayé ce code mais ça n'a pas marché :
Code:
1 2 3 4 5 6
| Url = "https://ftspluss.com/GBDD-INT/d92519280.02.a00.tar?B&csrfToken="
LocalFilename = "d92519280.02.a00.tar"
DestinationDir = objFolderItem.Path & "\" & "APPEL\"
Call DownloadFileFromUrl(Url, LocalFilename, DestinationDir) |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| Public Function DownloadFileFromUrl(ByVal Url As String, ByVal LocalFilename As String, ByVal DestinationDir As String)
' Download a file from a given url to specified directory
Dim WinHttpReq As Object, oStream As Object
Dim TimerOut As Integer
On Error Resume Next
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", Url, False
WinHttpReq.send
If Err.Number = 0 And WinHttpReq.Status = 200 Then
'Write response to file
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.responseBody
oStream.SaveToFile DestinationDir & LocalFilename
oStream.Close
Set oStream = Nothing
Else
MsgBox LocalFilename & " could not be download !"
End If
'free memory
Set WinHttpReq = Nothing
End Function |
Merci d'avance