Download and Rename Images Using Excel

Download images from a URL and easily set image names of the downloaded files using an excel enabled macro file.

Excel Macro source 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

Sub Sample()
    Dim FolderName As String
    Dim ws As Worksheet
    Dim LastRow As Long, i As Long
    Dim strPath As String
FolderName = Range("$B$2").Value
    Set ws = Sheets("Sheet1")

    LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row

    For i = 4 To LastRow
        strPath = FolderName & ws.Range("A" & i).Value & ".jpg"

        Ret = URLDownloadToFile(0, ws.Range("B" & i).Value, strPath, 0, 0)

        If Ret = 0 Then
            ws.Range("C" & i).Value = "Downloaded"
            ws.Range("C" & i).Value = "Error"
        End If
    Next i
End Sub

Sample File:


Since childhood, the technology of computers was his greatest fascination. Empowered with a degree on Computer Science from AMA University in the Philippines, Ron focused on website and program development. Since then, he has been working with different companies and personalities to achieve their corporate and personal goals by providing technical support for their online presence and program solutions. As today’s technology develops faster than the blink of an eye, Ron never stops exploring not only the new but the coming. His exposure to a wide array of businesses and industries equipped him to be versatile and proficient to go beyond the expectations of his clients. Ron is looking forward to more challenging collaborations where he can further improve his ability to apply the latest trends in providing innovative solutions to the growing demands of website and program development.

Did this work for you?