[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=If]#If[/URL] VBA7 Then
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _
(ByVal pCaller As LongPtr, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As LongPtr) As Long
Private Declare PtrSafe Function DeleteUrlCacheEntry Lib "Wininet.dll" Alias "DeleteUrlCacheEntryA" _
(ByVal lpszUrlName As String) As Long
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=Else]#Else[/URL]
Private Declare 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
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" Alias "DeleteUrlCacheEntryA" _
(ByVal lpszUrlName As String) As Long
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=End]#End[/URL] If
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Public Sub Download_Images()
Dim lr As Long, r As Long
Dim saveInFolder As String
saveInFolder = ThisWorkbook.Path & ""
If Right(saveInFolder, 1) <> "" Then saveInFolder = saveInFolder & ""
With ActiveSheet
lr = .Cells(Rows.Count, "L").End(xlUp).Row
For r = 2 To lr
DownloadFile .Cells(r, "L").Value, saveInFolder & .Cells(r, "M").Value & ".jpg"
Next
End With
End Sub
Private Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim retVal As Long
DeleteUrlCacheEntry URL
retVal = URLDownloadToFile(0, URL, LocalFilename, BINDF_GETNEWESTVERSION, 0)
If retVal = 0 Then DownloadFile = True Else DownloadFile = False
End Function