Home > front end >  How to Apply this VBA to Several Slides in PowerPoint?
How to Apply this VBA to Several Slides in PowerPoint?

Time:03-11

This code works brilliantly for automatically returning the viewer from Slide 3 to 'previous slide viewed' but it seems to only be applicable to one slide. For example, I want to apply it to every odd numbered slide in index (ie 3,5,7,9,11, etc) but then it stops working...

Sub OnSlideShowPageChange()
With ActivePresentation.SlideShowSettings
    .LoopUntilStopped = msoCTrue
    .AdvanceMode = ppSlideShowUseSlideTimings
    .ShowType = ppShowTypeWindow
    .Run
   End With
   
    Dim i As Integer
    i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
    If Not i = 3 Then Exit Sub
    With SlideShowWindows(1).View

     .GotoSlide (.LastSlideViewed.SlideIndex), msoFalse
    End With

End Sub

Any help would be greatly appreciated!

CodePudding user response:

So I didn't code vba for some years but if I understand your snippet correctly it e.g. stops the presentation from advancing from page 2 to page 3 (by sending the presentation to the previous page)

if you now want to apply this to every odd page you could rewrite line 11 to:

If Not i Mod 2 > 0 Then Exit Sub

it works for me. please correct me if I understood the task wrong.

CodePudding user response:

Here is a link to some alternative solutions to this problem, as well as one that allows the versatility to easily add a slide number into a case for each slide that should return the viewer to 'LastSlideViewed'.

http://www.vbaexpress.com/forum/showthread.php?69713-How-to-Apply-this-VBA-to-more-than-just-Slide-3

  • Related