Rich (BB code):
Public Function DownloadFile_WEB(sURL As String, _
sDestPath As String, _
sDestFileName As String) As Boolean
'https://www.anagrafenazionale.interno.it/wp-content/uploads/ANPR_archivio_comuni.csv
'Se il download va a buon fine restituisce True
Dim WinHttpReq As Object
Dim oStream As Object
Dim sBody As Variant
Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
On Error Resume Next
With WinHttpReq
.setTimeouts 50000, 50000, 50000, 50000
.Open "GET", sURL, False
.Send
If .Status = 200 Then
sBody = .responseBody
Set oStream = CreateObject("ADODB.Stream")
With oStream
.Open
.Type = 1
.Write sBody
If Right(sDestPath, 1) <> "" Then
sDestPath = sDestPath & ""
End If
.SaveToFile sDestPath & sDestFileName, 2 '2 sovrascrive
.Close
End With
End If
End With
Set WinHttpReq = Nothing
Set oStream = Nothing
Call LEGGI_FILE
End Function
I need to check if i can call LEGGI_FILE
actually is to the and of code but sure not is a correct choice...