Show me the next unhidden slide
Problem
Sometimes you need to know what the next UNHIDDEN slide is rather than simply the next slide in the presentation.
Solution
The NextUnhiddenSlide Function below takes a single parameter, the index of the slide you want to start searching from, and returns the slide index of the next unhidden slide following it, or 0 if there are no unhidden slides following.
The TestMe Subroutine demonstrates how you'd use the function.
Function NextUnhiddenSlide(lStartingSlideIndex As Long) As Long ' Returns the next unhidden slide following the slide at lStartingSlideIndex Dim x As Long Dim oPres As Presentation Set oPres = ActivePresentation For x = lStartingSlideIndex + 1 To oPres.Slides.Count If Not oPres.Slides(x).SlideShowTransition.Hidden Then NextUnhiddenSlide = x Exit Function End If Next End Function Sub TestMe() Dim x As Long Dim y As Long For x = 1 To ActivePresentation.Slides.Count y = NextUnhiddenSlide(x) If y > 0 Then Debug.Print "Current slide:" & vbTab & x & vbTab & "Next unhidden:" & vbTab & y Else Debug.Print "Current slide:" & vbTab & x & vbTab & "Next unhidden:" & vbTab & "NONE" End If Next End Sub
See How do I use VBA code in PowerPoint? to learn how to use this example code.