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:

  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) How do I enter a formula in a cell using VBA (using Absolute Reference)?

2) How to disable ability to insert Rows and Columns in Excel (using VBA)?

3) How to read a value from a cell in vba in Excel

4) How do I copy a Table from one location to another and retain all formulas, formats and columnwidths?

5) I have a macro that takes a lot of time for execution - how can I keep the user informed that the macro is running?

6) Vba code to password protect workbook in Excel

7) How can I clear cell after activating a routine when there is a change in value of a cell?

8) How can I filter and copy only filtered data using VBA?

9) Vba clear the contents of an entire sheet in Excel

10) How do I restrict user entry in ActiveX Text Box to just numeric values?

11) How can I add a Timestamp after macro execution?

12) Vba delete entire row if contains certain text in Excel

13) How can I list all files in a folder using VBA?

14) How can I set Page orientation, Zoom % , Title Rows and footer using VBA?

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