OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Find and remove animations associated with a bookmark or specific to shape on a bookmark trigger

We learnt how to add a bookmark trigger here. Let us look at how to remove all the triggers associated with a bookmark and also bookmarks triggers associated with a shape.

Supported versions: PowerPoint 2010


Sub TestIt()

'To remove all the bookmark triggers on the 2nd shape on the slide
Call RemoveBookmarkTriggersForShape(ActivePresentation.Slides(1), ActivePresentation.Slides(1).Shapes(2))

'To remove all the bookmark triggers for "Bookmark 3"
Call RemoveTriggersForBookmark(ActivePresentation.Slides(1), "Bookmark 3")

End Sub

Sub RemoveBookmarkTriggersForShape(oSld As Slide, oShp As Shape)
Dim I As Long
Dim J As Long
'Enumerate all the triggers on the slide timeline
For I = oSld.TimeLine.InteractiveSequences.Count To 1 Step -1
    For J = oSld.TimeLine.InteractiveSequences(I).Count To 1 Step -1
        'Check if it is a bookmark trigger and delete it if it matches the shape name

        With oSld.TimeLine.InteractiveSequences(I).Item(J)
            If .Timing.TriggerType = msoAnimTriggerOnMediaBookmark Then
                If .Shape.Name = oShp.Name Then
                    .Delete
                End If
            End If
        End With
    Next
Next
End Sub

Sub RemoveTriggersForBookmark(oSld As Slide, Bookmark As String)
Dim I As Long
Dim J As Long
For I = oSld.TimeLine.InteractiveSequences.Count To 1 Step -1
    For J = oSld.TimeLine.InteractiveSequences(I).Count To 1 Step -1
        With oSld.TimeLine.InteractiveSequences(I).Item(J)
            If .Timing.TriggerType = msoAnimTriggerOnMediaBookmark Then
                'Check for matching bookmark and delete it
                If .Timing.TriggerBookmark = Bookmark Then
                    .Delete
                End If
            End If
        End With
    Next
Next
End Sub

 

 


Copyright 1999-2014 (c) Shyam Pillai. All rights reserved.