Results 1 to 9 of 9

Thread: VBA Command to delete all shapes in specific PPT slides

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Mar 2016
    Posts
    47
    Location

    VBA Command to delete all shapes in specific PPT slides

    Hi all,

    I got a perfectly working VBA macro, but it deletes all shapes on ALL slides in the active PowerPoint.

    Sub DeleteAllGraphsInPPT()
    'This macro will only work if there is an active PowerPoint
    'It removes all shapes, pictures and tables in the active PowerPoint
        Dim objApp, objSlide, ObjShp, objTable
        On Error Resume Next
        'Is the PowerPoint open?
        Set objApp = CreateObject("PowerPoint.Application")
        On Error GoTo 0
        'If the presentation is open, check each slides for shapes, pictures and/or tables
        'and deletes them if they exist
        For Each objSlide In objApp.ActivePresentation.Slides
        For Each ObjShp In objSlide.Shapes
        If ObjShp.Type = msoPicture Then
        ObjShp.Delete
        ElseIf ObjShp.Type = msoTable Then
        ObjShp.Delete
        ElseIf ObjShp.Type = msoChart Then
        ObjShp.Delete
        End If
        Next
        Next
    End Sub
    Is it possible to modify it and only delete all shapes from slides 2 until 8?

    Yours sincerely,

    Djani
    Last edited by Djani; 05-19-2016 at 07:30 AM. Reason: info

Posting Permissions

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