Copying objects in Powerpoint using VB

Joined
May 26, 2012
Messages
1
Reaction score
0
Hi.

I'm trying to copy all the objects on a slide in an open presentation (where the macro originated from) to a new presentation created by the macro.

It is working intermittently and keeps crashing. Not very sure what is wrong.

I need to copy all the objects from one presentation to another, but without copying the slides since the size of the slide needs to change, but not the objects.

This is the code I have right now

If Presentations.Count = 2 Then
If Presentations(1).Slides.Count = 0 Then
Set BookletPrint = Presentations(1)
Set BookletEdit = Presentations(2)
Else
Set BookletPrint = Presentations(2)
Set BookletEdit = Presentations(1)
End If
For l = 1 To cnt_old
BookletPrint.Slides.Add l, ppLayoutBlank
If Presentations(1).Slides.Count > cnt_old Then
Set BookletEdit = Presentations(1)
ElseIf Presentations.Count <> 2 Then
Exit Sub
Else
Set BookletEdit = Presentations(2)
End If
If BookletEdit.Slides(l + 1).Shapes.Count > 0 Then
BookletEdit.Slides(l + 1).Shapes.Range.Copy
If Presentations(1).Slides.Count > cnt_old Then
Set BookletPrint = Presentations(2)
ElseIf Presentations.Count <> 2 Then
Exit Sub
Else
Set BookletPrint = Presentations(1)
End If
BookletPrint.Slides(l).Shapes.Paste
End If
Next l

cnt_old is the number of slides in the first presentation.

Thanks!!
 

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