Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to convert image URLs to actual images in Excel?

If you have a list of image URL addresses in column A, and now, you want to download the corresponding pictures from the URLs and display them into the adjacent column B as following screenshot shown. In Excel, how could you extract the actual pictures from the image URLs quickly and easily?

doc url to image 1

Convert the image URLs to actual images with VBA code


Covert file name to actual images at once in Excel:

With Kutools for Excel's Match Import Pictures feature, you can quickly import multiple images into the corresponding cells based on the file names.

doc url to image 2

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


arrow blue right bubble Convert the image URLs to actual images with VBA code

The following VBA code can help you quickly extract the actual images from the image URL addresses, please do as this:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Convert the image URLs to actual images:

Sub URLPictureInsert()
'Updateby Extendoffice 20161116
    Dim Pshp As Shape
    Dim xRg As Range
    Dim xCol As Long
    On Error Resume Next
    Application.ScreenUpdating = False
    Set Rng = ActiveSheet.Range("A2:A6")
    For Each cell In Rng
        filenam = cell
        ActiveSheet.Pictures.Insert(filenam).Select
        Set Pshp = Selection.ShapeRange.Item(1)
        If Pshp Is Nothing Then GoTo lab
        xCol = cell.Column + 1
        Set xRg = Cells(cell.Row, xCol)
        With Pshp
            .LockAspectRatio = msoFalse
            .Width = 100
           .Height = 100
            .Top = xRg.Top + (xRg.Height - .Height) / 2
            .Left = xRg.Left + (xRg.Width - .Width) / 2
        End With
lab:
    Set Pshp = Nothing
    Range("A2").Select
    Next
    Application.ScreenUpdating = True
End Sub

Note: In the above code, A2:A6 is the range of cells which contains the URL addresses you want to extract the images, and also you can change the size of the image width and height to your need in the Width = 100, Height = 100 scripts.

3. Then press F5 key to run this code, and all corresponding pictures have been extracted from the image URLs to the adjacent column at once, see screenshot:

doc url to image 1


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Ronnie · 19 days ago
    hey! with the Help of the Vba Code the Image has been extracted to the sheet but as i am moving my workbooks location the Image are Corrupted so help me here
  • To post as a guest, your comment is unpublished.
    karim · 2 months ago
    working perfect
    thanks a lot
  • To post as a guest, your comment is unpublished.
    Jo · 3 months ago
    if the url is in https, for sure there is no way to work around it?
  • To post as a guest, your comment is unpublished.
    Karthik Karthik · 4 months ago
    Hello I'm here asking for your help. My research ended up in 2 different macros that combined will give a good utility for my work.
    1. Will insert image as comment, 2. Will fetch Hyperlinks(Local folder path only, not web based URL) and paste them in destination cell
    I really tried to combine them to do one job, but I guess I don’t have enough knowledge on this.
    I need the images to be inserted as comment as the 1st code does to the destination range user selects.

    Sub InsertPictureAsComment()
    Dim PicturePath As String
    Dim CommentBox As Comment
    With Application.FileDialog(msoFileDialogFilePicker)
    .AllowMultiSelect = True
    .title = "Select Comment Image"
    .ButtonName = "Insert Image"
    .Filters.clear
    .Filters.Add "Images", "*.png; *.jpg"
    .Show
    'Store Selected File Path
    On Error GoTo UserCancelled
    PicturePath = .SelectedItems(1)
    On Error GoTo 0
    End With
    'Clear Any Existing Comment
    Application.ActiveCell.ClearComments
    'Create a New Cell Comment
    Set CommentBox = Application.ActiveCell.AddComment
    'Remove Any Default Comment Text
    CommentBox.Text Text:=""
    'Insert The Image and Resize
    CommentBox.Shape.Fill.UserPicture (PicturePath)
    CommentBox.Shape.ScaleHeight 6, msoFalse, msoScaleFormTopLeft
    CommentBox.Shape.ScaleWidth 4.8, msoFalse, msoScaleFromTopLeft
    'Ensure Comment is Hidden (Swith to TRUE if you want visible)
    CommentBox.Visible = False
    Exit Sub
    'ERROR HANDLERS
    UserCancelled:
    MsgBox "Done"
    End Sub

    Sub URLToCellPictureInsert()
    'Updateby Extendoffice 20180608
    Dim Pshp As Shape
    Dim xRg As Range
    Dim xCol As Long
    On Error Resume Next
    Set Rng = Application.InputBox("Please select the url cells:", "KuTools for excel", Selection.Address, , , , , 8)
    If Rng Is Nothing Then Exit Sub
    Set xRg = Application.InputBox("Please select a cell to put the image as comment:", "KuTools for excel", , , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    For i = 1 To Rng.Count
    filenam = Rng(i)
    ActiveSheet.Pictures.Insert(filenam).Select
    Set Pshp = Selection.ShapeRange.Item(1)
    If Pshp Is Nothing Then GoTo lab
    xCol = cell.Column + 1
    Set xRg = xRg.Offset(i - 1, 0)
    With Pshp
    .LockAspectRatio = msoFalse
    .Width = 80
    .Height = 80
    .Top = xRg.Top + (xRg.Height - .Height) / 2
    .Left = xRg.Left + (xRg.Width - .Width) / 2
    End With
    lab:
    Set Pshp = Nothing
    Range("A2").Select
    Next
    Application.ScreenUpdating = True
    End Sub
    • To post as a guest, your comment is unpublished.
      Sharath · 23 hours ago
      Before first End Sub Call the Module URLToCellPictureInsert and remove the msgbox Done paste before 2nd End sub

      Like this: Call URLToCellPictureInsert
  • To post as a guest, your comment is unpublished.
    Chile · 7 months ago
    Hello

    I try to get 33 images from URL but only gives me 1, all URL paths to the images are correct... what can that be?