Click here to Skip to main content
15,793,045 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I need to write a PowerPoint VB macro to paste the same image on all my slides (inserting it on the Master slide does not work as it remains in the background and gets overlaid with large pictures in the foreground).

I have found (and adapted) the following snippet:

Sub SuperDuper()
    Dim x As Long

    For x = 1 To ActivePresentation.Slides.Count

End Sub

it does execute the Paste operation, but the pasting location changes from slide to slide. How can I fix this ?

I have used this code:
ActiveWindow.Selection.ShapeRange(1).Name = shapeName
With NewPres.Slides(SlideNumber).Shapes(shapeName)
    .Height = gridHeight
    .Width = gridWidth
    .Left = gridLeft
    .Top = gridTop
    .ZOrder gridZOrder
End With

After it pastes it is still selected so you can then give it a name and reference it that way and set it's various properties.
Share this answer
YvesDaoust 7-Oct-13 10:57am    
Thanks for the suggestion
ZurdoDev 7-Oct-13 11:10am    
No problem.
YvesDaoust 7-Oct-13 11:22am    
I assume (not tested) that you can do without naming the shape:
With ActiveWindow.Selection.ShapeRange(1)
End With
ZurdoDev 7-Oct-13 11:30am    
Likely. I was using it more in the code later so I did, but yes, I believe that would also work.
Here is my final, cleaned-up script. Very simple once you know the recipe:
Sub PasteToAll()
    For i = 1 To ActivePresentation.Slides.Count
        Set MyRange = ActivePresentation.Slides(i).Shapes.Paste
        MyRange(1).Left = 100
        MyRange(1).Top = 100
End Sub
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900