Reputation: 38228
Is there some kind of event which allows to run a macro any time one enters a slide or leave a slide ?
Upvotes: 7
Views: 31560
Reputation: 1250
I'd like to add that event to use really depends on the version of PowerPoint. For me (PP 2007) the next event works quite stable:
Sub OnSlideShowPageChange(ByVal objWindow As SlideShowWindow)
Debug.Print objWindow.View.Slide.SlideIndex ' you can use this to check which slide invokes the event
End Sub
This code does not need additional class structures (PPTEvent). But if you plan to use other events it's a good idea to put initialization of this class into OnSlideShowPageChange.
Please note, this code copes with the first part of the task given - entering the slide. You may ask "What about its leaving?". Well, this is a matter of relativity. What's entering for one slide is at the same time leaving for another. Just use objWindow.View.Slide.SlideIndex to track the current slide, compare it with the previous slide's index and decide if you've just left the needed one.
Upvotes: 0
Reputation: 61056
SlideShowNextSlide or OnSlideShowPageChange
You can find the full list at http://officeone.mvps.org/vba/events_version.html
Code sample from http://msdn.microsoft.com/en-us/library/aa211571%28office.11%29.aspx
This example determines the slide position for the slide following the SlideShowNextSlide event.
If the next slide is slide three, the example changes the type of pointer to a pen and the pen color to red.
Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
Dim Showpos As Integer
Showpos = Wn.View.CurrentShowPosition + 1
If Showpos = 3 Then
With ActivePresentation.SlideShowSettings.Run.View
.PointerColor.RGB = RGB(255, 0, 0)
.PointerType = ppSlideShowPointerPen
End With
Else
With ActivePresentation.SlideShowSettings.Run.View
.PointerColor.RGB = RGB(0, 0, 0)
.PointerType = ppSlideShowPointerArrow
End With
End If
End Sub
Upvotes: 6