VBA Macro: How to Run a Custom Code When A Slide Changes during Slideshow in PowerPoint

If you are interested to run a custom code when the slide changes during the slideshow, then here is a VBA script snippet that you can modify to run your own code. Basically what we are going to do is to use the OnSlideShowPageChange() event at the presentation level to detect when the slide is changed during a slideshow in PowerPoint 2010, but you can also use this snippet in PowerPoint 2007 and 2013.

Sub OnSlideShowPageChange()
    Dim i As Integer
    i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
    If i <> 1 Then Exit Sub
    MsgBox "Insert your code here"
End Sub

You can copy this VBA snippet into your PowerPoint presentation using the developer tools and then change the part when it says MsgBox with your own custom VBA code.

Leave a Comment

Your email address will not be published. Required fields are marked *