Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping Through Charts / ChartObjects | Excel Programming | |||
Looping through charts in a worksheet | Excel Programming | |||
Looping through to stop on pie charts | Excel Programming | |||
Looping Through Charts | Excel Programming | |||
Looping Through Charts | Excel Programming |