Copy multiple charts to an array?

S

shelfish

Ok, I've searched this group for while and cannot find any solution to
this so here goes...

Please ignore syntax errors as this is strongly paraphrased from the
actual code. I'm just looking for a way to accomplish the
objective....
********************************************************************************
Dim PictureArray as variant = Array(chart1, chart2, chart3....)
Dim elementCount as int = PictureArray.Elements.count
Dim i

'COPY EXCEL CHARTS TO ARRAY AS PICTURES
For i = 1 To elementCount

With PictureArray(i)
.Select
[some code removed]

'COPY CHART AS PICTURE
PictureArray(i) = .CopyPicture(Appearance:=xlScreen,
Size:=xlScreen, Format:=xlPicture)

End With
Next

'START POWERPOINT
Set PPApp =
CreateObject("PowerPoint.Application")
PPApp.Visible = True

'NEW PRESENTATION
Set PPPres = PPApp.Presentations.Add

[more code removed]

'ADD NEW SLIDE TO THE END
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1,
ppLayoutTitleOnly)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex


'PASTE PICTURE ARRAY ELEMENTS
For i = 1 To elementCount
With PPSlide

'PASTE IMAGE FROM ARRAY
On Error Resume Next
.Shapes.Paste (copyPasteArray(i))
.Shapes(i + 1).Select

End With
Next
*****************************************************************************************

This last part just pastes the last item copied to the clip board. So
the question is, how do I do all the copying and then all the
pasting.

Many thanks for any assistance offered.

S.
 
J

Jon Peltier

You have to loop through the list of charts, and in each loop, copy one
chart, then paste it, then in the next loop, copy another chart, then paste
it.

- Jon
 
S

shelfish

Damn it! I thought that might be the answer, I just didn't want to
admit it. This will require some serious rework. Thanks for the answer
just the same.

S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top