Excel lacks any user-accessible support for this functionality, but you can either easily work around this or dig in to VBA, where this functionality is provided:
"One-shot" export
- Select the graph (the whole graph, not an internal component; so select the border).
- Copy it (ctrl-c, right-click copy, whatever you like).
- Open MS Paint.
- Paste (you may wish to minimise the image size first, it will get enlarged to fit, but not shrunk).
- Save as desired.
Bulk export
You would probably want to look at using ActiveChart.Export
in a VBA macro, this lets you specify a file path and then lets Excel do the work.
Below is a working prototype that I've just put together. Run this and every chart in the active workbook will be exported to the same folder as that file, in PNG format, with _chart##
appended to the file name (where ##
is an increasing number).
It doesn't perform any safety checks (so will overwrite files!) and doesn't contain any error checking. It will not work if you haven't yet saved the workbook, the location is read-only or anything else that prevents writing to the file's location. I have only tested this in Excel 2003 (as that's all I have to hand at the moment).
In other words: Use at your own risk, this is intended as a basic working example only.
'small nicety to ensure two-digits for better file sorting'
Function NiceFileNumber(num As Integer) As String
If num < 10 Then
NiceFileNumber = "0" & num
Else
NiceFileNumber = num
End If
End Function
'the real function'
Sub ExportAllCharts()
Dim i As Integer, exportCount As Integer
Dim fileNum As String, fileBase As String
Dim sheetObj As Worksheet
Dim chartObj As Chart
'current file location and name, with extension stripped'
fileBase = Left(ThisWorkbook.FullName, InStrRev(ThisWorkbook.FullName, ".") - 1)
exportCount = 0
'First, export all charts that are in their own sheets'
For Each chartObj In ActiveWorkbook.Charts
fileNum = NiceFileNumber(exportCount)
exportCount = exportCount + 1
'Do the export'
chartObj.Export fileBase & "_chart" & fileNum & ".png"
Next
'Then, export all charts that are embedded inside normal sheets'
For Each sheetObj In ActiveWorkbook.Worksheets
For i = 1 To sheetObj.ChartObjects.count
fileNum = NiceFileNumber(exportCount)
exportCount = exportCount + 1
'Do the export'
sheetObj.ChartObjects(i).Activate
ActiveChart.Export fileBase & "_chart" & fileNum & ".png"
Next i
Next
End Sub
Note: I've encased the comments in '
s at both ends, which isn't needed, but helps make sure they're coloured correctly here.
Here's an explanation and a link to an Excel Add-In (free) that will do it for you: Enhanced Export Chart Procedure
– Jon Peltier – 2011-12-01T16:22:11.957