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!
Microsoft ExcelVisual Basic ClassicVB Script

Avatar of undefined
Last Comment
daviddiebel

8/22/2022 - Mon
vb_elmar

To delete the chart try this:

ActiveSheet.ChartObjects(i).Delete
ASKER CERTIFIED SOLUTION
byundt

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
daviddiebel

ASKER
Thank you - perfect!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy