logo
search
Office Settings & Configuration

How to Run a VBA Macro During a PowerPoint Animation

Camila MilosovichCamila Milosovich Oct 12, 2026 870 views

Question details

The user wants to find a way to trigger and execute a VBA macro while a PowerPoint animation sequence is actively playing.

How to Run a VBA Macro During a PowerPoint Animation
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.
Before you start

Ensure your presentation is saved as a Macro-Enabled Presentation (.pptm) and that you have enabled macros in your Trust Center settings.

Solution 1Recommended

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.

1
Insert a Trigger Shape

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.

2
Add a Mouse-Over Action

Select the newly created shape, navigate to 'Insert' > 'Action', and click on the 'Mouse Over' tab.

3
Assign the Macro

Select the 'Run macro' radio button, choose your desired VBA macro from the dropdown list, and click 'OK'.

4
Animate the Shape

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.

Use the Mouse-Over Action Workaround
Cursor Movement Requirement: The mouse-over action only fires when the system registers the cursor moving from outside the shape onto it. If the mouse is completely stationary when the shape appears, the event might not trigger reliably.
Run Macros Seamlessly in WPS Presentation

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. 1. Enable Macros: Open WPS Presentation, navigate to the 'Developer' tab, and ensure macros are enabled for your file.
  2. 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. 3. Animate and Present: Apply custom animations to your trigger shapes and start your slideshow to see your automated scripts in action.
Fully compatible with Microsoft PowerPoint (.pptm) files and existing VBA scriptsBuilt-in VBA editor for creating, debugging, and managing macros seamlesslyEasily assign macros to shapes and buttons via intuitive Action settingsLightweight application that runs smoothly even during resource-heavy animations
microsoft office alternative - wps office

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.