VBA & Macro Problems

Run a PowerPoint Macro on Multiple Slides Automatically

Tauseeq MagsiTauseeq Magsi Nov 13, 2026 869 views

Question details

Run one PowerPoint VBA macro on multiple slides, either through action buttons or automatically during a slide show.

Run the Same PowerPoint Macro on Multiple Slides
Product
Microsoft PowerPoint
Device & OS
not provided
Scenario
A presentation needs to reuse the same macro across slides or trigger it when the slide show advances.
Observed behavior
The same macro can be called from multiple slide buttons or from a slide-show event without clicking a button.
Before you start

Use a desktop version of PowerPoint that supports VBA, and save the presentation as a PowerPoint Macro-Enabled Presentation (.pptm). Enable macros only if you trust the presentation and its code.

Solution 1Recommended

Trigger the macro with a slide-show event

Use a PowerPoint application event to call the same macro automatically as the slide show moves between slides.

PowerPoint application events require a class module with a WithEvents variable. The SlideShowNextSlide event runs immediately before the transition to the next slide; it can also fire when a slide show starts.

1
Create an event class

Open Developer > Visual Basic, select the presentation's VBA project, and choose Insert > Class Module. In the Properties window, set its Name to CSlideShowEvents.

2
Add the event handler

Paste this code into CSlideShowEvents: Public WithEvents App As PowerPoint.Application Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow) RunSharedMacro End Sub

3
Add and initialize the macro

Choose Insert > Module and add the following code. Replace the Debug.Print line with the actions you want to perform: Public SlideEvents As CSlideShowEvents Public Sub StartSlideEvents() Set SlideEvents = New CSlideShowEvents Set SlideEvents.App = Application End Sub Public Sub RunSharedMacro() Debug.Print "Slide show event fired" End Sub

4
Start the event handler

Return to PowerPoint, select Developer > Macros, run StartSlideEvents, and then start the presentation from Slide Show > From Beginning. Advance through the slides to test the event.

Trigger the macro with a slide-show event
Initialize each session: Run StartSlideEvents again after reopening the presentation or resetting the VBA project. The event handler remains active only while its VBA object is retained.
Free Microsoft Office alternative

Edit presentations with WPS Presentation

WPS Office is a free, lightweight alternative with a familiar interface for editing presentations. Open common PowerPoint files to move your slide work to WPS; PowerPoint VBA event behavior is not guaranteed to work in WPS.

Create and edit slides in a familiar presentation interfaceOpen and edit Microsoft PowerPoint PPT and PPTX filesMove existing presentations into WPS for everyday slide editingUse a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Does each slide need its own copy of the macro?

No. Store one public macro in a standard VBA module and assign it to action buttons on multiple slides, or call it from a slide-show event handler.

Why does the automatic macro stop working after I reopen the presentation?

The event object must be initialized again. In PowerPoint, select Developer > Macros and run StartSlideEvents before starting the slide show.

What file format should I use for PowerPoint VBA?

Choose File > Save As and select PowerPoint Macro-Enabled Presentation (.pptm) to retain the VBA code.

When does SlideShowNextSlide run?

It fires immediately before the transition to the next slide and can also fire when a slide show starts. Use the event handler to call your shared macro.

Why is my action button not running the macro?

Check the button's Action Settings and confirm that Run macro is selected with the correct macro name. Test it in Slide Show view, and make sure macros are enabled for the trusted presentation.