Converting A Image URL To Actual Image in Excel

Status
Not open for further replies.

RyGUY1446

New Member
Joined
Apr 11, 2013
Messages
1
How can I convert a Image URL in excel to an actual image? I'm looking to take a url in column A and show the image in column B but also only have the image be certain size?

I've tried this but kept getting an error.

"Dim url_column As Range
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;">Dim image_column As RangeSet url_column = Worksheets(1).UsedRange.Columns("A")Set image_column = Worksheets(1).UsedRange.Columns("B")Dim i As LongFor i = 1 To url_column.Cells.Count With image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value) .Left = image_column.Cells(i).Left .Top = image_column.Cells(i).Top image_column.Cells(i).EntireRow.RowHeight = .Height End WithNext"</code></pre>
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

John_w

MrExcel MVP
Joined
Oct 15, 2007
Messages
7,898
Try this:
Code:
Sub InsImg()

    Dim URL As Range
        
    For Each URL In Range("A1", Cells(Rows.Count, "A").End(xlUp))
        With URL.Parent.Pictures.Insert(URL.Value)
            .Left = URL.Offset(0, 1).Left
            .Top = URL.Offset(0, 1).Top
            URL.EntireRow.RowHeight = .Height
        End With
    Next

End Sub
If you got an error with your code, it helps if you tell us exactly what the error is and on which line it occurs.

Also, please put code within [ CODE] and [ /CODE] tags (without the spaces).
 
Upvote 0

ahobbs01

New Member
Joined
Jan 13, 2023
Messages
12
Office Version
  1. 365
Platform
  1. Windows
I have images that are several different sizes. I used this code to see if it would extract the image in the next cell without changing the size of the image. It worked for some of the images but then errored out.

1684787484951.png

1684787461568.png
 
Upvote 0

Marius44

Board Regular
Joined
Aug 30, 2016
Messages
55
HI
I think the suggestion for this line of code
For Each URL In Range("D2:D712", Cells(Rows.Count, "D").End(xlUp))
it must be changed so
VBA Code:
For Each URL In Range("D2", Cells(Rows.Count, "D").End(xlUp))
HI,
Mario
 
Upvote 0

ahobbs01

New Member
Joined
Jan 13, 2023
Messages
12
Office Version
  1. 365
Platform
  1. Windows
HI
I think the suggestion for this line of code
For Each URL In Range("D2:D712", Cells(Rows.Count, "D").End(xlUp))
it must be changed so
VBA Code:
For Each URL In Range("D2", Cells(Rows.Count, "D").End(xlUp))
HI,
Mario
I am still getting the same error after making that change.
1684788325169.png
 
Upvote 0

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
85,165
Office Version
  1. 365
Platform
  1. Windows
Duplicate to: Converting a Image URL to Actual Image Size

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,195,952
Messages
6,012,500
Members
441,702
Latest member
chacham

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top