PDA

View Full Version : Export all the sheets in excel to images individually files



majhe2143
08-19-2017, 07:29 PM
Hello excel experts,I am new to this vba coding ....
I am looking for code that which can able to export all the sheets in excel to images individually files.
I want to export each and every sheet in excel worbook to indiviudal images in .png or .jpg format at best quality.
sheet 1 to be saved as image1.jpg
sheet 2 to be saved as image2.jpg
in this way.....

thank you in advance.

YasserKhalil
08-19-2017, 09:32 PM
Hello
What if the sheet has more than one page?

YasserKhalil
08-19-2017, 09:41 PM
Cross-Post at this link
http://chandoo.org/forum/threads/exporting-each-and-every-sheet-in-excel-worbook-to-indiviudal-images.35511/

majhe2143
08-20-2017, 03:35 AM
I want what ever images or shapes present in sheet1 ,to be exported as one single image file.
in that way ,other sheets too.
like screen shots of every sheet in that workbook.
sheet1 as one single image and sheet2 as other single image.
In that way in one click all the sheets to be exported as images individually to a folder.

YasserKhalil
08-20-2017, 04:23 AM
Hello
Create a folder named "TestFolder" in the same path of your workbook and try this code


Sub Test()
Dim ws As Worksheet
Dim rng As Range
Dim fname As String
Dim objPic As Shape
Dim objChart As Chart


Application.DisplayAlerts = False
For Each ws In ThisWorkbook.Worksheets
Set rng = ws.UsedRange
fname = ws.Name
rng.CopyPicture xlScreen, xlPicture
Sheets.Add , Sheets(Sheets.Count)

With Sheets(Sheets.Count)
.Shapes.AddChart
.Activate
.Shapes.Item(1).Select
Set objChart = ActiveChart
.Shapes.Item(1).Width = rng.Width
.Shapes.Item(1).Height = rng.Height
objChart.Paste
objChart.Export (ThisWorkbook.Path & "\TestFolder\" & fname & ".jpg")
.Delete
End With
Next ws
Application.DisplayAlerts = True
End Sub