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

How to use msoAnimEffectPlayVideoFromBookmark

Don't waste your time trying to look over the help files for this because it is just not there. You can use this enum to set an animation effect or trigger effect to seek a specific point in a media file and play from it. However there is a bit of a stumbling block involved because a bug in the OM causes it not to work as expected. But we will get it working right by addressing the bug.

See also: Media Format and Bookmarks

Supported versions: PowerPoint 2010+



Sub UseMsoAnimEffectPlayVideoFromBookmark()
Dim oShp As Shape         ' Shape trigger

Dim oShpMovie As Shape    ' Media shape
 
With ActivePresentation.Slides(1).Shapes

    Set oShpMovie = .AddMediaObject2("C:\Videos\sample.wmv", False, True)

    Set oShp = .AddShape(msoShapeRectangle, 10, 10, 100, 50)

End With

With ActivePresentation.Slides(1)

    ' Create three bookmarks on the video at desired points
    Call oShpMovie.MediaFormat.MediaBookmarks.Add(10000, "Bookmark A")

   Call oShpMovie.MediaFormat.MediaBookmarks.Add(20000, "Bookmark B")
   Call oShpMovie.MediaFormat.MediaBookmarks.Add(30000, "Bookmark C")
 
    ' Create an animation sequence to start playing playing from the second bookmark
   ' When you use the msoAnimEffectMediaPlayFromBookmark enum value PowerPoint assigns 
   ' the first bookmark as the starting point for the video, to change that you need 
   ' to edit the bookmark property
    With .TimeLine.MainSequence.AddEffect(oShpMovie, msoAnimEffectMediaPlayFromBookmark)

        .Behaviors(1).CommandEffect.bookmark = "Bookmark B"

   End With

    
    ' Create a shape trigger to start playing from the third book.
   ' Don't set the bookmark name in the AddTriggerEffect call, it will be ignored
    With .TimeLine.InteractiveSequences.Add.AddTriggerEffect(oShpMovie, _

                    msoAnimEffectMediaPlayFromBookmark, _

                    msoAnimTriggerOnShapeClick, oShp)

            .Behaviors(1).CommandEffect.bookmark = "Bookmark C"

   End With
End With

End Sub

 


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