VBA Macro: How to Run a Custom Code When A Slide Changes during Slideshow in PowerPoint
Last updated on August 18th, 2024
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.
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.