export pictures from excel file

doriannjeshi

Board Regular
Joined
Apr 5, 2015
Messages
214
Office Version
  1. 2019
Platform
  1. Windows
Hi, I have an excel file which has several hundreds pictures embeded in cells in .jpg format I want to export them all How can I do it ?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi

You cannot embed pictures in cells so I guess you mean that you placed the pictures on top of cells?

If that's the case you just have to save a copy of the file as Web Page and you'll get all the images as separate files in the files subfolder.
 
Upvote 0
thanks for the tip , but the jpegs are being saved not by their names How do I make the jpegs keep their names ?
 
Upvote 0
Hi

You are rigth. You get all the files but you lose the names that they have in the worksheet.

If I also wanted the names then I'd then I'd use another method, with vba

2 options
- use a chart object to export all the pictures, saving each with the name they have in the worksheet, for ex.
or
- get the picture files and parse the xml sources for the names (in the xl->(media,drawing) subfolders)

For the first options there are lots of examples available (also here in mrexcel). If you don't know how to do it and can't find examples post back.
For the second option, you have to look into the xml sources for the workbook, open those files and parse them. If you are not used to it, maybe the first option is easier.

Does this help?
 
Upvote 0
I don't have any experience with either option :( How do I use a chart object to export the pictures ?
 
Upvote 0
This is an example. It exports the pictures in worksheet "Sheet1" to a folder using the picture names.

Assumes that the pictures names are valid file names and unique.

Try:

Code:
'PGC 201212
' Export pictures from a worksheet to a folder
Sub ExportRangeJPG()
Dim ws As Worksheet
Dim chtO As ChartObject
Dim pic As Picture
Dim lPic As Long

Const sPathname = "c:\tmp\PicTest\"

Set ws = ActiveWorkbook.Worksheets("Sheet1")
Set chtO = ws.ChartObjects.Add(1, 1, 1, 1)

For lPic = 1 To ws.Pictures.Count

    Set pic = ActiveSheet.Pictures(lPic)
    
    ' resize the chartobject to the dimensions of the picture
    With chtO
        .Width = pic.Width
        .Height = pic.Height
    End With
    
    ' paste the picture into the chart object
    pic.Copy
    chtO.Chart.Paste
    
    ' export the chart to a file
    chtO.Chart.Export sPathname & ws.Pictures(lPic).Name & ".jpg"
    
Next lPic
    
' clean up
chtO.Delete

End Sub

Hope it works OK, haven't tried it for a while.
 
Upvote 0
It exports a white picture not with it's name but with name picture 7.jpg
 
Upvote 0
Well, I tried yesterday with excel 2007 and now with excel 2010. Works with no problems.

Check the initialisation of the destination folder and the input worksheet.
 
Upvote 0
The name not showing , named picture.. and a number The picture is ok but I need the name this is the path I am using Const sPathname = "E:\OneDrive\imazheprove\" name of the page is sheet1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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