Results 1 to 5 of 5

Thread: PPT VBA MACROS HELP (1)Delete all empty placeholders (2)Automate duplicate and delete

  1. #1
    VBAX Newbie
    Oct 2023

    Question PPT VBA MACROS HELP (1)Delete all empty placeholders (2)Automate duplicate and delete

    Hi there!
    I am very new to VBA and macros, but really loving the time these have been saving me!!! My curiosity is peaked.
    I have searched a lot for specific VBA's to do a few things but haven't found quite what I'm looking for, basically I am using powerpoint to create photography related things (easy to export slides as jpg or video).
    I'd love a hand creating these two macros if anyone would like to help

    Macro (1) removes all empty image placeholders from a slide (or entire presentation)
    why I need this: one of the files I've made starts with like 200 image placeholders that are stacked on each other (scattered). I drag and drop all the images I want to use into this one slide, but there could be just 90 images so I need to delete all the remaining empty image placeholders

    Macro (2) Duplicates the active slide, goes back to 1st slide, deletes the image + image placeholder and repeats until there are no more images/placeholders
    why I need this: working backwards (from having ALL images) I am removing one stacked image at a time so the starting slide shows only the bottom image. I save this out as a video so it looks like the pictures are stacking up on top of each other.

    Here is a screenshot of my process to help explain this

    and here is what the final ppt looks like in slide sorter

    I would be super grateful if someone could generously help automate this for me
    happy to buy you a coffee(s) or compensate, as this would be a massive time saver for me as a creative!

    Thank you!

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Dec 2005
    Welcome to VBAX ZoeZoe.

    Have you had a look here?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Newbie
    Oct 2023
    Thanks Aussiebear, I did see that thread but it's not a complete code (I don't know how to write VBA to properly include anything)
    I used chat PGT to help me make some coding but nothing has worked so far... I even asked it to reference that specific code with no luck.

    Still exploring the options :-(

  4. #4
    VBAX Master
    Feb 2007
    Try this for the first option

    Sub killPLC()'kill empty pic placeholders
    Dim osld As Slide
    Dim S As Long
    Dim counter As Long
    For Each osld In ActivePresentation.Slides
        For S = osld.Shapes.Count To 1 Step -1
            With osld.Shapes(S)
                If .Type = msoPlaceholder Then
                    If .PlaceholderFormat.Type = ppPlaceholderPicture Then
                        If Not .PlaceholderFormat.ContainedType = msoPicture Then
                            counter = counter + 1
                        End If
                    End If
                End If
            End With
        Next S
    Next osld
    MsgBox counter & " Placeholders deleted."
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials

  5. #5
    VBAX Newbie
    Oct 2023
    Thank you John, that worked to remove the images but it leaves behind the empty placeholder, a work around I've found it to drag and drop all my images into the template, then copy and paste them to a new slide with no template applied, this does not copy the empty placeholders so I end up with only the pictures.

    Also I have some VBA now that does what I needed for the rest, in case anyone is curious, this works for what I needed. I'm not sure why but bottom shape works to actually delete the top shape in the slide.

    Sub MOD_2___Duplicate_and_delete()
            ' Go to the first slide
        ActiveWindow.View.GotoSlide 1
        Dim slide As slide
        Dim bottomShape As shape
           Set slide = ActiveWindow.View.slide
        If slide.Shapes.Count > 0 Then
            ' Identify the bottom shape on the slide
            Set bottomShape = slide.Shapes(slide.Shapes.Count)
            ' Delete the bottom shape
        End If
    End Sub
    And then this VBA runs that 200 times - unless there's not shapes left, then it stops.
    Sub MOD_3___Duplicate_and_Delete_Repeat_200()
        Dim i As Integer
        Dim repeatCount As Integer
        repeatCount = 200 ' Change this to the number of times you want to repeat the macro
        For i = 1 To repeatCount
            ' Call your macro here
            ' Introduce a delay (e.g., 1 second) before the next iteration
            Dim startTime As Double
            startTime = Timer
            Do While Timer < startTime + 1
        Next i
    End Sub

    Thanks for the hand, seems I got it sorted though!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts