VBA & Macro Problems

Use PowerPoint VBA to Move Automatically Between Slides

Huma Ashraf ChHuma Ashraf Ch Nov 14, 2026 868 views

Question details

Automatically navigate between PowerPoint slides with VBA while preserving existing slide-index-based logic.

Product
Microsoft PowerPoint
Device & OS
not provided
Scenario
A presentation needs to return to a slide and replay its animations without inserting a slide that would change existing slide indexes.
Observed behavior
The desired result is event-driven navigation to an existing slide, using stable slide identifiers if slides are reordered.
Before you start

Save the presentation as a macro-enabled .pptm file and enable macros only if you trust its source. Identify the source and destination slides and check any existing slide-show event handlers for conflicting navigation.

Solution 1Recommended

Use a PowerPoint slide-show event and SlideID values

Use an application event to trigger navigation and find the destination reliably even after slides are reordered.

SlideShowNextSlide fires immediately before a slide transition. The slide reported by the event and the effect of a jump should be tested with your existing presentation logic.

SlideID values remain associated with their slides when slides are reordered. FindBySlideID resolves the destination to its current SlideIndex for GotoSlide.

1
Find the slide IDs

Open the VBA editor with Alt+F11, then open View > Immediate Window. Run ? ActivePresentation.Slides(2).SlideID, substituting the current slide index, and record the IDs for the source and destination slides.

2
Create an event class

In the VBA editor, select Insert > Class Module and name it CSlideEvents. Add this code, replacing 12345 and 67890 with your source and destination SlideIDs: Public WithEvents App As PowerPoint.Application Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow) Static navigating As Boolean Dim target As Slide If navigating Then Exit Sub On Error GoTo CleanUp If Wn.View.Slide.SlideID <> 12345 Then Exit Sub Set target = Wn.Presentation.Slides.FindBySlideID(67890) If target Is Nothing Then Exit Sub navigating = True Wn.View.GotoSlide target.SlideIndex, msoTrue CleanUp: navigating = False End Sub

3
Initialize the event handler

Select Insert > Module and add: Public SlideEvents As CSlideEvents Public Sub EnableSlideEvents() Set SlideEvents = New CSlideEvents Set SlideEvents.App = Application End Sub Run EnableSlideEvents from the Macros dialog before starting the slide show. The public variable keeps the handler available while VBA is running.

4
Test the slide show

Start the presentation from Slide Show and navigate through the source slide. Verify the jump and check existing macros for event loops or conflicting transitions; adjust the condition if the event reports a different slide than expected.

Use a PowerPoint slide-show event and SlideID values
Animation and audio behavior: The msoTrue argument requests that the destination slide be reset, which can replay its animations. Test any music separately, because audio playback also depends on its playback and animation settings.
Free Microsoft Office alternative

Edit PowerPoint Presentations with WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface for opening and editing PowerPoint files. It makes moving everyday presentation work straightforward, but it does not fix PowerPoint VBA event behavior; test macro-dependent features before switching.

Open and edit Microsoft PowerPoint PPT and PPTX filesWork with slides and animations in a familiar presentation interfaceUse a free, lightweight suite for everyday documents and presentationsMove compatible presentation files between Office suites
QA img-9

Frequently Asked Questions

Why use SlideID instead of SlideIndex?

A SlideIndex changes when slides are inserted, deleted, or reordered. A SlideID stays associated with its slide, so Slides.FindBySlideID can find its current index.

When does SlideShowNextSlide run?

PowerPoint raises SlideShowNextSlide immediately before a slide transition. Test the slide reported by Wn.View.Slide in your presentation before relying on it as a navigation condition.

Will GotoSlide replay animations and music?

Passing msoTrue as the ResetSlide argument requests a reset of the destination slide, allowing its animations to replay. Music behavior depends on its playback and animation settings, so test it in Slide Show mode.

Why does the event handler stop working after reopening the presentation?

VBA event objects must be initialized for the current session. Run EnableSlideEvents before the slide show, or arrange for trusted startup code to initialize the handler.