How to Control PowerPoint WMV Video Playback Using VBA
Question details
The user needs to use VBA to control the playback of an inserted WMV video file during a presentation.

- Product
- PowerPoint
- Device & OS
- not provided
- Scenario
- Writing a VBA macro to trigger, monitor, and stop a media object when running a presentation slide.
- Observed behavior
- Standard shape visibility properties do not work for controlling video media playback; instead, the slideshow player object must be invoked directly.
Ensure your presentation is saved as a Macro-Enabled Presentation (.pptm) so your VBA code is preserved. Also, verify the exact name of your WMV video shape in the Selection Pane before running the macro.
Use the SlideShowWindows Player Object for Video Control
The most reliable method to control media elements using VBA is by referencing the slideshow player rather than standard shape properties.
Because PowerPoint treats video files as media objects, simply hiding or showing the shape with VBA will not accurately control the video playback or its audio. You must specifically target the SlideShowWindows player object.
Open the Selection Pane (Home tab > Select > Selection Pane) and note or change the exact name of your inserted video shape (e.g., 'App Opening.wmv').
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor, then insert a new Module.
Define your shape and player variables. Reference the video using code like: Set oSh = ActivePresentation.Slides(1).Shapes("App Opening.wmv"). Then, link it to the player: Set opl = SlideShowWindows(1).View.Player(oSh.Id).
Use opl.Play to start the video. To ensure the macro waits for the video to finish before proceeding, add a loop: While opl.State = ppPlaying, followed by Wend. Finally, use opl.Stop to end the media session.

Seamlessly Manage Media and Macros with WPS Presentation
WPS Office provides a comprehensive presentation tool that fully supports inserting, managing, and automating media files like WMV videos. With high compatibility with Microsoft PowerPoint, you can easily run VBA macros and execute rich multimedia presentations seamlessly.
- 1. Insert Your Video: Open WPS Presentation, go to the 'Insert' tab, and select 'Video' to add your WMV file to the slide.
- 2. Access the Developer Tools: Navigate to the 'Developer' tab on the ribbon to access the Macro and VBA Editor.
- 3. Execute Your Macros: Paste your video control VBA code into the editor, ensure macro settings are enabled in the Trust Center, and run your slideshow.

Frequently Asked Questions
Why doesn't changing the visibility property hide my playing video?
In PowerPoint, video files are treated as rich media objects rather than simple graphic shapes. Even if you set the shape's visibility to hidden, the underlying media player object may continue to render the video frame or play audio. You must use the SlideShow Player's 'Stop' or 'Pause' commands instead.
How do I find the exact name of my video shape for the VBA code?
Go to the 'Home' tab, click on 'Select' in the Editing group, and choose 'Selection Pane'. This pane will list all objects on the current slide, including your video. You can double-click the name here to copy it or rename it for easier use in your VBA script.
Can I run this VBA code while in Edit mode?
No, the SlideShowWindows(1).View.Player object is only instantiated when the presentation is actively running in Slideshow mode. Running this code in Edit (Normal) mode will result in a VBA runtime error.
What does 'While opl.State = ppPlaying' do in the macro?
This creates a loop that effectively pauses the rest of your VBA macro execution as long as the video is currently playing. Once the video finishes, the state changes, the loop ends, and your macro moves on to the next instruction.




