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"
Err_Chart:
If Err <> 0 Then
Debug.Print Err.Description
Err.Clear
End If
End Sub
The code uses Export method to save the chart in graphics format
this is a best way to convert a excel sheet into a image file
ReplyDeleteIt works for me. I Love it !!!
ReplyDeleteIs there a way to do the same with a table/group of formatted cells? i.e. export as .JPEG using vba.
ReplyDeleteCan you check if the following works for you http://vbadud.blogspot.com/2010/06/how-to-save-excel-range-as-image-using.html
ReplyDeleteChanging the jpg line to a png allows for a crisper export.
ReplyDeleteoCht.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 !!
Can this be done with a shape object, such as a picture? I'm tearing my hair out on this. Excel 2003.
ReplyDeletebut image is not clear......
ReplyDelete