vba export chart as gif in Excel
Q192. In Excel, how can I export a chart as a gif file?
To do it in Excel, here is the answer:
- Option Explicit
- Sub ExportChart()
- Dim sFileName As String
- sFileName = ThisWorkbook.Path & "\" & "ChartExportSample.gif"
- ActiveSheet.ChartObjects("Chart1").Chart.Export Filename:=sFileName, FilterName:="GIF"
- End Sub
a) Line 4 - Set a name for the gif file and a folder to save it. The gif is set to be saved in the same folder as the workbook containing the macro.
b) Line 5 - Export the Chart as a "gif" in the folder specified with the name defined in line 4.