Sunday, March 15, 2009

How to Save a Chart as Image using Excel VBA

Here is the way to save the active chart in Excel 2007 to a JPG file. It is better to size the chart appropriately before exporting it as an image.

Sub Save_ChartAsImage()

Dim oCht As Chart

Set oCht = ActiveChart

On erRROR GoTo Err_Chart

oCht.Export Filename:="C:\PopularICON.jpg", Filtername:="JPG"


If Err <> 0 Then

Debug.Print Err.Description


End If

End Sub

The code uses Export method to save the chart in graphics format


  1. this is a best way to convert a excel sheet into a image file

  2. Anonymous10:36 AM

    It works for me. I Love it !!!

  3. Anonymous7:33 AM

    Is there a way to do the same with a table/group of formatted cells? i.e. export as .JPEG using vba.

  4. Can you check if the following works for you

  5. Changing the jpg line to a png allows for a crisper export.

    oCht.Export Filename:="C:\ExcelChartExport.png", Filtername:="png"

    Jpgs work well for pictures of people and things just not computer output..

    I also changed the name of the export..
    Thanks for the tip !!

  6. Anonymous8:24 AM

    Can this be done with a shape object, such as a picture? I'm tearing my hair out on this. Excel 2003.

  7. Anonymous12:58 AM

    but image is not clear......


Share on Facebook
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.