How to Insert images in cells in BULK from a corresponding hyperlink

Derek Fingleson

New Member
Joined
Jan 22, 2020
Messages
16
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Hi Guys

So here is my problem..
In Column A .. I have the hyperlinks of the images.. These are all on my local computer ( I have approx 7,000 rows of this )
I want to insert the image in the corresponding Cell in Column B
I can do it individually , ( Then have to resize image to say height 0.9" ) but this is crazy and time consuming..
How can I automate this ?

So for Example :-

Row Col A ... Col B
1 G:\Derek\Documents\RENDERED\ET 52 29 ST6.jpg Actual image
2. G:\Derek\Documents\RENDERED\ET 52 4VIEW.jpg Actual image
3. G:\Derek\Documents\RENDERED\ET 52 29 ST 5.jpg Actual image
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi,

Please check below code.

VBA Code:
Sub loadPicture()

Dim Pic_Location As String, picNumber As Integer
Dim cellLocation As Range
Dim Pic_Name As String, totalRows As Integer

'To check totalRows in column A
totalRows = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

For picNumber = 2 To totalRows
    Set cellLocation = ActiveSheet.Range("B" & picNumber)
    Pic_Location = ActiveSheet.Range("A" & picNumber)
    Set Pic = cellLocation.Parent.Pictures.Insert(Pic_Location)
    
    With Pic
        '.ShapeRange.LockAspectRatio = msoFalse
        .Top = Cells(picNumber, 2).Top
        .Left = Cells(picNumber, 2).Left
        .Height = 0.9 * 72
End With
Next
 
Upvote 0
Solution

Hi Saurabhj


This is fantastic... Thank you.. It works !!
Hi Saurabhj

I thought it worked... BUT BUT..

There is a problem.. So what happens is :-
When you save the file , close excel etc.. and Then reopen the file , it then stats trying to reinsert all the images again !
Now, I have 7,000 rows , so this takes hours to even reload ! ( Im sure the cells contain the link to the image? )

Is there a way to format the cells to simply have the image and NOT the link . ( I need to remove any Hyperlink in the pic )
So , somehow , I just need the image with ZERO cross link to where it came from .. ie any hyperlinks etc..
Also , I have tried to use Row 1 as the headings and create a filter.
So now when you filter , it starts all over again looking for the links and bringing back the images !

In the format of the picture, I also need to set the property to "Move and Size with Cell"

What are your thoughts on this ?

Regards
Derek
 
Upvote 0
Hi, I hope you are not executing the code on Workbook Open event.

The function is not creating any hyperlink. If the images are loaded then it's loaded. It might possible due to large number of images, making excel slow.

After loading all images, what is the file size ?
 
Upvote 0
Hi, I hope you are not executing the code on Workbook Open event.

The function is not creating any hyperlink. If the images are loaded then it's loaded. It might possible due to large number of images, making excel slow.

After loading all images, what is the file size ?
I reduced file to 4000 rows.. Size now 580KB ... Was like 3 times the size before !
Everything now working as planned... Thank You
 
Upvote 0
That's great. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,878
Messages
6,122,062
Members
449,064
Latest member
scottdog129

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
Back
Top