Home Products Customers Tips VBA OfficeOne on Mac Contact us

Run VBA macro at a particular slide

Microsoft PowerPoint fires the OnSlideShowPageChange() event for every slide that is shown during the slide show. You can use this facility to call any macro when certain slides are displayed. PowerPoint passes a reference to the SlideShowWindow as parameter to the OnSlideShowPageChange() event.

The following macro shows how to use OnSlideShowPageChange() event to display a message when the first slide is shown:

Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
    If SSW.View.CurrentShowPosition = _
        SSW.Presentation.SlideShowSettings.StartingSlide Then

       
MsgBox "First slide in the slide show"
    End If
End Sub

The following macro displays a message when the last slide is shown:

Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
    If SSW.View.CurrentShowPosition = _
        SSW.Presentation.SlideShowSettings.EndingSlide Then

        MsgBox "Last slide in the slide show"
    End If
End Sub

The following macro displays a message when the third slide is shown:

Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
    If SSW.View.CurrentShowPosition = 3 Then
        MsgBox "Third slide in the slide show"
    End If
End Sub

See Also: Events supported by PowerPoint


Home | Products | Tips | VBA | FAQ | Utilities | Disclaimer | Privacy Policy | Mac | Links | Contact us

Contact OfficeOne on email at officeone@officeoneonline.com. Copyright © 2001-2017 OfficeOne. All rights reserved.

page counter