How to Export images From excel as given Cells name?

Rexana

New Member
Joined
Jul 13, 2020
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
  2. Mobile
I have an Excel Sheet with 15000 Rows including Product Name in Column "A",
Including Product Images in Column "B".
Now, How can I export All of these Pictures in a Folder as Column A product name.
It will save My Day.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi and welcome to MrExcel

Try this:

VBA Code:
Sub Export_Images()
  Dim img As Shape, tempChart As ChartObject
  Dim sPath As String, sName As String
    
  sPath = "C:\trabajo\images\"          'folder name
  For Each img In ActiveSheet.Shapes
    If img.TopLeftCell.Column = 2 Then
      sName = img.TopLeftCell.Offset(0, -1).Value
      If sName <> "" Then
        img.CopyPicture xlScreen, xlPicture
        Set tempChart = ActiveSheet.ChartObjects.Add(0, 0, img.Width, img.Height)
        With tempChart
          .Border.LineStyle = xlLineStyleNone
          .Chart.Paste
          .Chart.Export sPath & sName & ".gif"
          .Delete
        End With
      End If
    End If
  Next
End Sub
 
Upvote 0
Hi There,
Thank you so much for your Code. it Works Almost but When I Run The Code in The Output Folder it Shows only Whiteboard Photos Instead of My Excel Column B Images.
See the Screen Shot, please!
Screenshot_1.png
 
Upvote 0
I have an Excel Sheet with 15000 Rows including Product Name in Column "A",
Including Product Images in Column "B".

You could share a file with only 2 of those images.

You could upload a copy of your file to a free site such www.dropbox.com or google drive. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0
Yes I can generate the files and I can see inside them the image:

1594678725242.png


In this line of the macro, instead of .gif, try another extension, for example .png or .jpg

VBA Code:
.Chart.Export sPath & sName & ".gif"
 
Upvote 0
I use a slightly different method to export pictures. Instead of
VBA Code:
img.CopyPicture xlScreen, xlPicture
I just use
VBA Code:
 img.copy
. Not sure if that would make a difference. You can see my code here, post #13.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

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