Convert Charts in Excel Worksheets Automatically to Images

How to convert charts in Excel worksheets automatically to different image formats with VBA.

Here’s the complete VBA code:

Sub ExportCharts()

Dim sht As Worksheet
Dim cht As ChartObject
Dim i As Integer
i = 1

Application.ScreenUpdating = False
Application.EnableEvents = False

Set sht = ActiveSheet

For Each sht In ActiveWorkbook.Worksheets
For Each cht In sht.ChartObjects
ActiveChart.Export ActiveWorkbook.Path & “\” & sht.Name & “-” & i & “.gif”
i = i + 1
Next cht
i = 1
Next sht

Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub