Convert image url to actual image in excel

Copper Contributor

I have a column of image URLs in my workbook and would like to show the actual image in the next column. Is there a formula or add in that can be used?

32 Replies

Hi Michael,

 

No formula can help in this regard!

You need a VBA code or a third-party add-in to view these images.

 

Please check out this link.

 

Hope that helps

I tried something similar to that. The issue I had was when I ran the module, the images loaded onto the spreadsheet in a stack or layered on top of each other instead of in cells. Do you know if I could make that happen?

You can easily change the Height and Width to make the images fit the cells.

Try to change the Height from 100 to 30 and the Width from 100 to 60.

 

.Width = 60
.Height = 30

I'm sorry, I meant that the images are not placed in the cells. They are floating and stacked on top of each other. Since I have over 1000 urls to convert, I wanted to know if there's a way to place the resulting images in cells.

I got the VBA to work.  My questions is there a snippet that can be added to the VBA code to make the image insert into a specif cell? For example, if the url is in cell C3 and I want the image to be in cell D3

Hi Michael,

 

The code is already programmed to place the image next to the link in the adjacent cell.

This is the result that I got when I run the code.

2019-01-07_19-46-17.png

 

Isn't that what you asking for?

That's EXACTLY what I'm looking for. But, When I run the code, the images are not placed inside cells. Would you please share with me the actual code you ran?

 

Thank you so much!

I've used the same code as in the link I mentioned before.

Sub URLPictureInsert()
'Updateby Extendoffice 20161116
'Update by Haytham 20180104

    Dim Pshp As Shape
    Dim xRg As Range
    Dim xCol As Long
    On Error Resume Next
    Application.ScreenUpdating = False
    Set Rng = ActiveSheet.Range("A2:A140")
    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 = 60
            .Height = 30
            .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

 

But I adjusted the Height and Width to make the images fit the cells.

Please note that the code may take up to 5 minutes to finish the process.

 

Hope that helps

I finally got it to work. I hadn't changed the insert cell location, just the url cell range.

Now I'm trying to figure out how to get the pics to scale with changing cell size. I've tried the following code  HERE  with no luck yet. Working with VBA is completely new to me. I appreciate your help and patience.

 

 

You can update the code like the following by adding this line to it:

Pshp.Placement = xlMoveAndSize

 

Sub URLPictureInsert()
'Updateby Extendoffice 20161116
'Update #1 by Haytham Amairah in 20180104
'Update #2 by Haytham Amairah in 20180108

    Dim Pshp As Shape
    Dim xRg As Range
    Dim xCol As Long
    On Error Resume Next
    Application.ScreenUpdating = False
    Set Rng = ActiveSheet.Range("A2:A140")
    For Each cell In Rng
        filenam = cell
        ActiveSheet.Pictures.Insert(filenam).Select
        Set Pshp = Selection.ShapeRange.Item(1)
        Pshp.Placement = xlMoveAndSize
        If Pshp Is Nothing Then GoTo lab
        xCol = cell.Column + 1
        Set xRg = Cells(cell.Row, xCol)
        With Pshp
            .LockAspectRatio = msoFalse
            .Width = 60
           .Height = 30
            .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

 

This will change the property for each image after inserting it to make it move and size with the cell.

Hi, I have a file having one column consist of many URLs and in next column I wish to convert these URLs into real images. I am using office 2007. Please find the file as attached. Kindly help me to convert this file . Looking forward. @Haytham Amairah 

Hi, I have a file having one column consist of many URLs and in next column I wish to convert these URLs into real images. I am using office 2007. Please find the file as attached. Kindly help me to convert this file . Looking forward.


@Haytham Amairah wrote:

Hi Michael,

 

No formula can help in this regard!

You need a VBA code or a third-party add-in to view these images.

 

Please check out this link.

 

Hope that helps


@Haytham Amairah 

Hi, I have a file having one column consist of many URLs and in next column I wish to convert these URLs into real images. I am using office 2007. Please find the file as attached. Kindly help me to convert this file . Looking forward.


@Haytham Amairah wrote:

Hi Michael,

 

No formula can help in this regard!

You need a VBA code or a third-party add-in to view these images.

 

Please check out this link.

 

Hope that helps


@Haytham Amairah 

Hi @rsinghal2019,

 

It seems that the links in the file aren't valid when you open them in the browser!

Therefore, I don't think that the solution is applicable to them.

 

 

 

 

@Haytham Amairah 

Hi this code is very helpful thank you

I was wondering if there is a way to actually download the images?

if i am understanding this the images we are seeing are just being generated from the link but are not hard files on the computer?

 

Thanks

Hi,

 

After you run the code, these pictures get saved locally in the workbook.

If you want to extract them into a folder outside Excel, the trick is to save the workbook as a Webpage (*htm; *html) using the Save As dialog box.

After then, go to the webpage folder and find them inside it.

 

Regards

 

@Alevizos 

@Haytham Amairah 

THANK YOU THANK YOU THANK YOU!!!!

you are an awesome individual thank you so much

@Haytham Amairah Thank you for providing this.

 

I am running hte macro and stepping through.... each cell (Pshp) evaluates as empty and moves to the "lab" but there are clearly URLs in my range.

 

I can see filenam is set properly but Pshp is always nothing.

 

Any thoughts on why that would happen?

@Rob O'Keefe

 

Hi,

 

We need to look into the range and the URLs to figure out the problem!

So, please provide the workbook or a dummy version of it.

 

Regards