View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default VBA to save a chart as a GIF

To export a range, you need to copy it into a blank chart, and export the
blank chart. Harald Staff wrote and David McRitchie posted an XL2GIF routine
that does this:

http://www.mvps.org/dmcritchie/excel/xl2gif.htm

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


"Barb Reinhardt" wrote in message
...
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