Insert Product Images to Excel Workbook

RockyRobin

Board Regular
Joined
Sep 19, 2013
Messages
57
Hi All

Complete Newbie here and am trying to enhance my knowledge of excel to stop myself taking hours to do jobs.

I have a stocklist that is currently in excel with product codes in column B. (eg 60080U-090)
I want to insert product images into column A. The product images are labelled as the style code (eg 60080U-090)

Now this is where you will chuckle, previously we have spent hours manually adding each image into the relevant cell and resizing.

I dont know much about macros/VBA but am more than willing to start learning.

If its any help:

Images are saved on a folder in the desktop labelled "Imagery"
The excel workbook is saved in the same folder and labelled "Stock"

Hope you guys can help me out and enlighten me.

Thanks in advance.
 
I can't reproduce that behaviour. How are you saving the workbook?


When I view the spreadsheet on another PC it says the link cannot be verified.
I would like to send the spreadsheet to other users without having to send the folder full of images too.

This is the last step I need to make this work.

Thanks for all your help so far Andrew.
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
For me saving the workbook saves the images embedded in it. I don't know why that wouldn't happen for you. What's the "VBA file"?
 
Upvote 0
If the VBA code is in the workbook it will be saved with it (provided that the extension is xls, xlsm or xlsb).

Once I ve run the macro and the images appear is there anything I should be doing before saving the spreadsheet.
Also on the VBA programme do I need to do anything with that once I've pasted in the code you gave me.

sorry for the questions but as this is the first time I've done this I'm a little unsure of all the steps.
 
Upvote 0
Once I ve run the macro and the images appear is there anything I should be doing before saving the spreadsheet.
Also on the VBA programme do I need to do anything with that once I've pasted in the code you gave me.

sorry for the questions but as this is the first time I've done this I'm a little unsure of all the steps.

As an update: the issue of the images not being attached was due to the fact I was using Excel 2010:-
Below is the adjusted code that works for Excel 2010

Code:
Sub Test()
    Dim Rng As Range
    Dim Cell As Range
    Application.ScreenUpdating = False
    Set Rng = Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row)
    For Each Cell In Rng
        With Cell
            On Error Resume Next
            .Parent.Shapes.AddPicture ThisWorkbook.Path & Application.PathSeparator & .Value & ".jpg", False, True, .Offset(, -1).Left, .Offset(, -1).Top, .Offset(, -1).Width, .Offset(, -1).Height
            If Err <> 0 Then
                Err.Clear
            End If
            On Error GoTo 0
        End With
    Next Cell
    Application.ScreenUpdating = True
End Sub

Massive thanks to Andrew for helping find a solution to this request.!!!
 
Last edited by a moderator:
Upvote 0
As an update: the issue of the images not being attached was due to the fact I was using Excel 2010:-
Below is the adjusted code that works for Excel 2010

Code:
Sub Test()
    Dim Rng As Range
    Dim Cell As Range
    Application.ScreenUpdating = False
    Set Rng = Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row)
    For Each Cell In Rng
        With Cell
            On Error Resume Next
            .Parent.Shapes.AddPicture ThisWorkbook.Path & Application.PathSeparator & .Value & ".jpg", False, True, .Offset(, -1).Left, .Offset(, -1).Top, .Offset(, -1).Width, .Offset(, -1).Height
            If Err <> 0 Then
                Err.Clear
            End If
            On Error GoTo 0
        End With
    Next Cell
    Application.ScreenUpdating = True
End Sub

Massive thanks to Andrew for helping find a solution to this request.!!!

Hi

When i try and apply a data filter to the spreadsheet, the filter applied to a particular column doesnt seem to adjust all the images correctly. Is there a way to ensure the filter works alongside the inserted images.
 
Upvote 0
This code is so beautiful. It brings a tear to my eyes :)
I have been trying and debugging code for the past week and always a run time error.

When I pasted this code it just worked. No hickups, no errors.

My project, item list file with item code, description, and item rates in excel.
Image directory that has jpg files that are named similarly to the excel item codes.

This macro helped me import the images and now I need to convert the images to base64 and then upload to our erp system.

As mentioned, I have imported the images successfuly and now im trying to convert the photos into base64 code and paste it into cell C.

I have tried some code but still am unable.

Please assist.


Cheers
Hussain
 
Upvote 0

Forum statistics

Threads
1,223,377
Messages
6,171,743
Members
452,419
Latest member
mapa

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