Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default looping through chartobjects returns deleted charts also

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?

--
_________________
Rolf @ Questus ans


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default looping through chartobjects returns deleted charts also

Deleted charts are not retained in the ChartObjects collection to the best
of my knowledge. How are you deleting your charts.

Why do you get the Temporary Folder within the loop. why not get it once
outside the loop and be done with it.

--
Regards,
Tom Ogilvy

"Rolf Barbakken" wrote in message
...
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?

--
_________________
Rolf @ Questus ans




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default looping through chartobjects returns deleted charts also

I saw that thing with the tempfolder after I posted, but it was not
important for the real problem.

The users delete their chart the normal user way: they select the chart and
press "Delete". I notice that in the loop through the collection the
index-numbers increase if you delete and insert new charts - i.e. the
collection length increases and loop takes more time.

"Tom Ogilvy" wrote in message
...
Deleted charts are not retained in the ChartObjects collection to the best
of my knowledge. How are you deleting your charts.

Why do you get the Temporary Folder within the loop. why not get it once
outside the loop and be done with it.

--
Regards,
Tom Ogilvy

"Rolf Barbakken" wrote in message
...
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?

--
_________________
Rolf @ Questus ans






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping Through Charts / ChartObjects William Benson[_2_] Excel Programming 2 June 29th 05 01:47 AM
Looping through charts in a worksheet Grant Excel Programming 1 August 6th 04 09:22 AM
Looping through to stop on pie charts Daniel Bonallack[_2_] Excel Programming 1 July 13th 04 06:11 PM
Looping Through Charts Mike Waldron[_2_] Excel Programming 1 May 21st 04 06:21 PM
Looping Through Charts No Name Excel Programming 1 May 20th 04 10:36 PM


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"