Export Chart


Posted by steve mielnicki on February 01, 2002 11:15 AM


I would like to export a chart as a GIF.

I'm adding an XLT template file before reading
in my data from file. From VBScript using ActiveSheet and
ActiveChart, I get blank graphs.

this does not work

oExcel.ActiveSheet.ChartObjects(1).Chart

If I import External Data from a text file from
the Excel menu, the chart draws itself automagically.
But using the VB from the recorded macro yields
a blank graph, which tells me that maybe I have
not identified the Chart object correctly.

How do I identify the chart in the new worksheet
and access it, getting it to draw the graph ?

thanks



Posted by Ivan F Moala on February 01, 2002 5:08 PM

Something like this example may help you

'You could try this routine that saves all charts
'generated on a worksheet to your active work book dir as a gif file....a few changes will
'get you what you want,

Sub ChartPict_save()
Dim sFName As String
Dim Pict As Object
Dim ch
Dim i As Integer

i = 1
For Each Pict In ActiveSheet.ChartObjects
Set ch = Pict.Chart
sFName = ThisWorkbook.Path & Application.PathSeparator & "temp" & i & ".gif"
ch.Export Filename:=sFName, FilterName:="GIF"
i = i + 1
Next
Set ch = Nothing
End Sub


'Ivan