Rajesh Sonawane
New Member

>>> use code - tags <<<
Code:
Option Explicit
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, _
ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Dim Ret As Long
'~~> This is where the images will be saved. Change as applicable
Const ParentFolderName As String = "D:\DSR Visibility tracker\"
Sub Download()
Dim ws As Worksheet
Dim LastRow As Long, i As Long
Dim Folderpath, strPath As String
Set ws = Sheets("Sheet1")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LastRow
Folderpath = ParentFolderName & ws.Range("A" & i).Value & "\"
If Len(Dir(Folderpath, vbDirectory)) = 0 Then
MkDir Folderpath
End If
strPath = Folderpath & "File" & i & ".jpg"
Ret = URLDownloadToFile(0, ws.Range("B" & i).Value, strPath, 0, 0)
If Ret = 0 Then
ws.Range("C" & i).Value = "File successfully downloaded"
Else
ws.Range("C" & i).Value = "Unable to download the file"
End If
Next i
End Sub
Last edited by a moderator: