Link to home
Start Free TrialLog in
Avatar of daviddiebel
daviddiebel

asked on

Replace all charts with pictures on a worksheet?

I'm trying to copy all charts on a worksheet as pictures, and then delete all of the original charts.  What I have for code right now is:

Sub ConvertCharttoPicture()

Dim i As Integer
Dim intX As Integer

For i = 1 To ActiveSheet.ChartObjects.Count
        ActiveSheet.ChartObjects(i).Activate
        ActiveSheet.ChartObjects(i).Select
        ActiveChart.ChartArea.Select
        ActiveChart.CopyPicture _
        Appearance:=xlPrinter, Size:=xlScreen, Format:= _
        xlPicture
        ActiveChart.Paste

Next

End Sub

One problem is that I cannot figure out how to delete the original chart.  The second problem is that this loops indefinitely, going over the same chart, again and again.  Any assistance at making this work would be great!  I intend to use this on many, many worksheets as part of another macro.

Thank you!
Avatar of vb_elmar
vb_elmar
Flag of Germany image

To delete the chart try this:

ActiveSheet.ChartObjects(i).Delete
ASKER CERTIFIED SOLUTION
Avatar of byundt
byundt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of daviddiebel
daviddiebel

ASKER

Thank you - perfect!