Forum Discussion
Michael Lovice
Jan 04, 2019Copper Contributor
Convert image url to actual image in excel
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?
Michael Lovice
Jan 07, 2019Copper Contributor
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!
Haytham Amairah
Jan 07, 2019Silver Contributor
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