Hi everybody,
I have to download a lot of files. I have URL for each of them.I listed all urls in one excel column.
The problem is when I save the second file. When VBA goes and check for the second url, find the file and when try to save it, the code shows me an error because is another file in the same folder with the same name
How i can put an index so from file1 to go file2?
Sub test()
Dim myURL As String
For I = 2 To 4
myURL = Worksheets("sheet1").Range("A2")
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False
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 ("C:\Users\verbamore\Desktop\1.pdf")
oStream.Close
End If
Next I
End Sub
Bookmarks