How to export charts to graphics in Excel?
In Excel, sometimes, you may generate some charts from the data, so that the data looks more visual and direct. If you want to save or export the charts to graphics for some purpose, how could you do?
The following VBA code can help you to export a selected chart from the active worksheet as a picture. And the picture will be saved in the same location as the workbook you applied. Do as follows:
1. Select the chart that you want to export.
2. Then Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module Window.
VBA:Export chart to graphic
Option Explicit Sub ExportChart() Const sSlash$ = "/" Const sPicType$ = ".gif" Dim sChartName$ Dim sPath$ Dim sBook$ Dim objChart As ChartObject On Error Resume Next Set objChart = ActiveSheet.ChartObjects(1) If objChart Is Nothing Then MsgBox "No charts have been detected on this sheet", 0 Exit Sub End If If ActiveChart Is Nothing Then MsgBox "You must select a single chart for exporting ", 0 Exit Sub End If Start: sChartName = Application.InputBox("Please Specify a name for the exported chart" & vbCr & _ "There is no default name available" & vbCr & _ "The chart will be saved in the same folder as this file", "Chart Export", "") If sChartName = Empty Then MsgBox "You have not entered a name for this chart", , "Invalid Entry" Goto Start End If If sChartName = "False" Then Exit Sub End If sBook = ActiveWorkbook.Path sPath = sBook & sSlash & sChartName & sPicType ActiveChart.Export Filename:=sPath, FilterName:="GIF" End Sub
4. Then press the F5 key to run this code, and enter the name for the exported chart in the prompt box, see screenshot:
5. And then click OK, the selected chart has been exported to Gif format, and saved in the same location as the original file. See screenshot:
With the above VBA code, you can only export one chart at a time, if you want to export other charts, please select other chart first, and then export it with the code.
Kutools for Excel’s Export Graphics utility can export multiple charts, pictures or shapes at once in Excel.
|Kutools for Excel, with more than 300 handy functions, makes your jobs more easier.|
After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)
1. Click Kutools Plus > Import / Export > Export Graphics, see screenshot:
2. In the Export Graphics dialog box, all of the charts, pictures and shapes have been listed in the left list box, specify the type that you want to export, then click button to specify a directory to save the exported graphics, at the same time, you can choose the format of the pictures from the Export format as you need, such as GIF, JPEG, TIF or PNG.
3. Then click OK, all the charts, pictures and shapes have been exported to the specified location successfully. See screenshots:
Please click Export Graphics to know more about this feature.
Export Range to File