How to Run a VBA Macro During a PowerPoint Animation
Question details
The user wants to find a way to trigger and execute a VBA macro while a PowerPoint animation sequence is actively playing.

- Product
- PowerPoint
- Device & OS
- not provided
- Scenario
- Creating complex presentations or generating videos that require precise timing controls, such as a synchronized countdown timer.
- Observed behavior
- PowerPoint animations do not natively trigger Action button mouse events, making it impossible to launch macros directly from an animation step without workarounds.
Ensure your presentation is saved as a Macro-Enabled Presentation (.pptm) and that you have enabled macros in your Trust Center settings.
Use the Mouse-Over Action Workaround
Attach a macro to a shape and trigger it using a mouse-over action when the shape is animated to appear on screen.
Since an animation itself cannot click a button or trigger code natively, you can rely on the cursor's position on the screen. By animating an invisible or strategically placed shape to appear exactly where the mouse pointer rests, the macro will execute automatically.
Go to the 'Insert' tab, select 'Shapes', and draw a shape on your slide in an area where the mouse cursor will be positioned during the presentation.
Select the newly created shape, navigate to 'Insert' > 'Action', and click on the 'Mouse Over' tab.
Select the 'Run macro' radio button, choose your desired VBA macro from the dropdown list, and click 'OK'.
Go to the 'Animations' tab, apply an 'Appear' animation to the shape, and adjust its timing in the Animation Pane so it appears exactly when you need the macro to run.

Utilize the Application.SlideShowNextBuild Event
Capture application-level events to trigger your VBA code automatically build-by-build during a slideshow.
Generate the Animation Entirely Using VBA
For precise timing controls, such as a fast countdown timer for video exports, bypass built-in animations and generate the visual changes directly via VBA loops.
Create and Run Advanced Macros in WPS Presentation
WPS Presentation provides robust support for VBA macros and Action settings, enabling you to build complex, interactive slideshows efficiently. Execute macros seamlessly while maintaining full compatibility with your existing presentations.
- 1. Enable Macros: Open WPS Presentation, navigate to the 'Developer' tab, and ensure macros are enabled for your file.
- 2. Assign Actions: Insert a shape from the 'Insert' tab, select it, and click 'Action Settings' to link your macro using Mouse Click or Mouse Over.
- 3. Animate and Present: Apply custom animations to your trigger shapes and start your slideshow to see your automated scripts in action.

Frequently Asked Questions
Can a PowerPoint animation directly trigger a macro?
No, built-in PowerPoint animations do not include direct triggers or mouse operations for executing macros. You must use workarounds like mouse-over actions on animated shapes or application-level VBA events.
Why isn't my mouse-over macro running when the shape appears?
For a mouse-over action to trigger, the system must register a physical movement of the cursor from outside the shape's boundary to inside it. If the presenter's mouse is completely stationary when the shape appears underneath it, the macro may fail to fire.
What is the best way to create a fast countdown timer for exporting a slide to video?
While you can use built-in exit/entrance animations for basic timers, they may not process fast enough or synchronize well when rendering to video. Generating the countdown entirely using a VBA loop provides superior, predictable timing control.




