Vba export chart as gif in Excel

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub ExportChart()
  3. Dim sFileName As String
  4. sFileName = ThisWorkbook.Path & "\" & "ChartExportSample.gif"
  5. ActiveSheet.ChartObjects("Chart1").Chart.Export Filename:=sFileName, FilterName:="GIF"
  6. End Sub

Description:

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.

 

You can find similar Excel Questions and Answer hereunder

1) Here some explanations about the MSXML who stands for Microsoft XML core services

2) Introduction to tables in Excel VBA and how to use tables, create tables in VBA

3) How can I avoid a gap in a line chart for missing data?

4) The name manager in Excel is very useful to keep an overview and manage all the variable names in Excel. Here how to use the name manager in VBA

5) Determine if hyperlinks are valid in Excel

6) How can I protect / unprotect WorkSheet using VBA?

7) Import txt file in Excel

8) How do I enter a formula in a cell using VBA (using Relative Reference)?

9) How to rename multiple sheets easily with VBA

10) How can I convert Column numbers into Column names for use in range definition?

 

Here the previous and next chapter