View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default VBA to save a chart as a GIF

Hey Jon, I have another related question. How would I save workbook level
named range "YTD_Summary" as a GIF image?

Thanks again,
Barb

"Jon Peltier" wrote:

If the chartobject's name is in fact "myName.gif", this should work. No need
to select worksheet or chart object, but you need to export the chart, not
the parent chartobject.

For Each WS In aWB.Worksheets
For Each ChtObj In WS.ChartObjects

If ChtObj.Name = "myName.gif" Then
fname = aWB.Path & "\myFileName.gif"
ChtObj.Chart.Export Filename:=fname, FilterName:="GIF"
End If
Next ChtObj
Next WS

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Barb Reinhardt" wrote in message
...
I have the following snippet of code to save a chart as a GIF. What am I
missing?

For Each WS In aWB.Worksheets
For Each ChtObj In WS.ChartObjects

If ChtObj.Name = "myName.gif" Then
fname = aWB.Path & "\myFileName.gif"
WS.Select
ChtObj.Select
ChtObj.Export Filename:=fname, FilterName:="GIF"
End If
Next ChtObj
Next WS


Thanks,
Barb Reinhardt