hello
i want to make e code for downloading files from web with scheduled time, i want to get the links form the sheet A1:A5, and the files to be named from B1:B5, and download time between links to be 5 mins .
I tried to make some code but it only download the firs link, naming dont work as i wanted and i cant figure how to make the schedule download.
Please some help here i have searched the net but i dint find something similar sow this will be useful for lot of peoples
i want to make e code for downloading files from web with scheduled time, i want to get the links form the sheet A1:A5, and the files to be named from B1:B5, and download time between links to be 5 mins .
I tried to make some code but it only download the firs link, naming dont work as i wanted and i cant figure how to make the schedule download.
Please some help here i have searched the net but i dint find something similar sow this will be useful for lot of peoples
Code:
Sub adds()
'for i = 1 to 5
For x = 1 To 5
Worksheets("sheet1").Select
Worksheets("sheet1").Activate
myURL = "http://img.chandoo.org/hw/max-change-problem.xlsx"
sFilename = Environ("SystemDrive") & Environ("HomePath") & _
Application.PathSeparator & "Desktop" & Application.PathSeparator & _
"test.xlsx"
'myURL As string
myURL = Cells(x, 1)
'sFilename As String
sFilename = Environ("SystemDrive") & Environ("HomePath") & _
Application.PathSeparator & "Desktop" & Application.PathSeparator & _
"Cells(2, x).XML"
Dim WinHttpReq As Object, oStream As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False ', "username", "password"
WinHttpReq.Send
myURL = WinHttpReq.ResponseBody
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.ResponseBody
oStream.SaveToFile sFilename, 2 ' 1 = no overwrite, 2 = overwrite
oStream.Close
End If
Next x
'next i
End Sub