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?
Haytham Amairah
Jan 08, 2019Silver Contributor
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.
Gunhild_Oterhals
Aug 18, 2021Copper Contributor
This really made my day Haytham Amairah! 🙂 I was wondering if it's possible to add something to the VBA to append the url to the image as well? So the result is a image that you can click to view the original in browser?