View Single Post
 
Old 10-12-2012, 12:07 PM
Colin Legg's Avatar
Colin Legg Colin Legg is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

So it's the chart class, not the chartobject class which has an export method. This worked fine for me (I set up a chart before running the code):

Code:
Sub foo()
    Dim cto As ChartObject
    Dim cht As Chart
    
    'get a reference to the chartobject on the sheet
    Set cto = Sheet1.ChartObjects(1)
    
    'get a reference to the chart
    Set cht = cto.Chart
    
    'export the chart as a jpg
    cht.Export "C:\Temp\MyChartPic.jpg", "JPG"
    
End Sub
Reply With Quote