Jan 04 2019 07:55 AM
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?
Jan 04 2019 08:58 AM
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
Jan 04 2019 09:56 AM
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?
Jan 04 2019 11:20 AM
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
Jan 04 2019 11:23 AM
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.
Jan 07 2019 08:27 AM
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
Jan 07 2019 09:49 AM
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.
Isn't that what you asking for?
Jan 07 2019 10:46 AM
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!
Jan 07 2019 11:05 AM
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
Jan 07 2019 11:53 AM
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.
Jan 07 2019 07:48 PM
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.
Apr 08 2019 07:36 PM
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
Apr 08 2019 08:02 PM
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
Apr 08 2019 08:02 PM
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
Apr 10 2019 01:24 PM
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.
May 15 2019 03:09 PM
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
May 16 2019 06:31 PM
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
May 17 2019 11:27 AM
Dec 14 2019 06:58 AM - edited Dec 14 2019 07:17 AM
@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?
Dec 14 2019 07:47 PM
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