Does anyone know how to download a file (without opening a webpage), and save it to a directory in Visual Basic 6.0?
Try this
Sub DownloadFile(url, path)
Dim objReq
Dim objStream
Set objReq = CreateObject("MSXML2.XMLHTTP")
objReq.Open "GET", url, False
objReq.send
If objReq.Status = 200 Then
Set objStream = CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.Write objReq.ResponseBody
objStream.Position = 0
objStream.SaveToFile path, 2
objStream.Close
Set objStream = Nothing
End If
Set objReq = Nothing
End Sub