Export Chart as a picture

Ease of Use


Version tested with


Submitted by:



Exports a selected chart from the activesheet as a picture, saved in the same path as the file. 


At times it is useful to be able to take a picture of your chart and paste it elsewhere, or even to mimic an unlinked or "dead" chart that doesn't update. This code saves a user selected chart, and saves it in the same file location as a gif. The chart picture can then be used however needed. 


instructions for use


Option Explicit Sub ExportChart() ' Export a selected chart as a picture Const sSlash$ = "/" Const sPicType$ = ".gif" Dim sChartName$ Dim sPath$ Dim sBook$ Dim objChart As ChartObject On Error Resume Next ' Test if there are even any embedded charts on the activesheet ' If not, let the user know Set objChart = ActiveSheet.ChartObjects(1) If objChart Is Nothing Then MsgBox "No charts have been detected on this sheet", 0 Exit Sub End If ' Test if there is a single chart selected 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", "") ' User presses "OK" without entering a name If sChartName = Empty Then MsgBox "You have not entered a name for this chart", , "Invalid Entry" GoTo Start End If ' Test for Cancel button If sChartName = "False" Then Exit Sub End If ' If a name was given, chart is exported as a picture in the same ' folder location as their current file sBook = ActiveWorkbook.Path sPath = sBook & sSlash & sChartName & sPicType ActiveChart.Export Filename:=sPath, FilterName:="GIF" End Sub

How to use:

  1. Copy the code
  2. Open the excel file it will be used in
  3. Press Alt + F11 to open the vbe
  4. From the menu bar > Insert > Module (Standard module)
  5. Paste the code in the open white window
  6. Press Alt + Q to close the vbe and return to excel

Test the code:

  1. If you dont have a chart on the sheet, make one
  2. Go to Tools > Macro > Macros
  3. Select "Export Chart" > Run
  4. You will prompted to give the chart a name
  5. After it's named, it will be saved in the same location as the excel file

Sample File:

ExportChartPic.zip 9.45KB 

Approved by mdmackillop

This entry has been viewed 200 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2014 VBA Express