Function DownloadFromURL(FileUrl As String, NewFullName As String)
Dim oXMLHTTP As Object, oStream As Object
On Error GoTo ERROR_EXIT
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
oXMLHTTP.Open "GET", FileUrl, False
oXMLHTTP.send
If oXMLHTTP.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oXMLHTTP.responseBody
oStream.SaveToFile NewFullName, 2
oStream.Close
DownloadFromURL = NewFullName
Else
DownloadFromURL = vbNullString
End If
GoTo EXIT_RUN
ERROR_EXIT:
DownloadFromURL = vbNullString
EXIT_RUN:
Set oXMLHTTP = Nothing
Set oStream = Nothing
End Function
Sub test()
DownloadFromURL "fileurl", "localpath"
End Sub