none
Powerpoint Macro - Cannot figure out how to Paste in Place (can only paste in MIddle) RRS feed

  • Question

  • Hi There,

    I have written a code for work in VBA (I am a beginner) and would like to take content from each slide and paste the slide content as a PNG. Essentially the intent is to "Lock" the deck so that anyone who has access cannot modify the information.

    Anyway, the code works great in that it will select all> cut all information>delete anything left on the slide>paste as PNG. However, I have not been able to figure out how to paste in the original position that everything was in. By default I set a paste in the middle. When I have a deck that is 170 slides, it can be annoying to have to review the position of each and every slide.

    My guess is that I may need to set a reference point when I first highlight everything, but I have no idea how to do this and utilize this position as a spot to paste.

    Here is my code:

    Sub test()
    Dim sld As Slide
    Dim pre As Presentation

    Set pre = ActivePresentation

    For Each sld In pre.Slides
        sld.Shapes.Range.Cut

        If sld.Shapes.Count > 0 Then
        sld.Shapes.Range.Delete
        sld.Shapes.PasteSpecial ppPastePNG

    ' Need to figure out how to paste in place here  

      sld.Shapes.Range.Align msoAlignCenters, msoTrue
        sld.Shapes.Range.Align msoAlignMiddles, msoTrue
        End If
       
        If sld.Shapes.Count = 0 Then
        sld.Shapes.PasteSpecial ppPastePNG

    ' Need to figure out how to paste in place here 

        sld.Shapes.Range.Align msoAlignCenters, msoTrue
        sld.Shapes.Range.Align msoAlignMiddles, msoTrue
        End If

    Next
    End Sub

    I appreciate the help!!

    Thursday, March 27, 2014 1:55 PM