R
Rolf Barbakken
What I want to do is to export all charts in my workbook as gifs. This works
fine, normally, but if I delete a chart, it will still be exported! The
exported gif is then empty. No image.
Here is the routine:
Dim wks As Worksheet
Dim cht As ChartObject
Dim strImage As String
Dim strPath As String
Dim objFSO As New FileSystemObject
For Each wks In ActiveWorkbook.Worksheets
wks.Activate
For Each cht In ActiveSheet.ChartObjects
strPath = objFSO.GetSpecialFolder(TemporaryFolder) & "\" &
cht.Name & ".gif"
strImage = strPath
gstrImage = strImage
cht.Chart.Export strImage, "GIF"
Next cht
Next wks
I have tried to find a way to detect if the chart is previously deleted,
because it seems Excel keeps the charts in the collection even if its
deleted, but the deleted charts does not show in the Worksheet.
How do I do this so that the deleted charts will not be exported?
fine, normally, but if I delete a chart, it will still be exported! The
exported gif is then empty. No image.
Here is the routine:
Dim wks As Worksheet
Dim cht As ChartObject
Dim strImage As String
Dim strPath As String
Dim objFSO As New FileSystemObject
For Each wks In ActiveWorkbook.Worksheets
wks.Activate
For Each cht In ActiveSheet.ChartObjects
strPath = objFSO.GetSpecialFolder(TemporaryFolder) & "\" &
cht.Name & ".gif"
strImage = strPath
gstrImage = strImage
cht.Chart.Export strImage, "GIF"
Next cht
Next wks
I have tried to find a way to detect if the chart is previously deleted,
because it seems Excel keeps the charts in the collection even if its
deleted, but the deleted charts does not show in the Worksheet.
How do I do this so that the deleted charts will not be exported?