none
PowerPoint 2010 Go to next section RRS feed

  • Question

  • I have got a power point with several sections. I would like to create a macro for going to the next section when in the middle of a power point. Then I will be able to add an action button to go to the next section.

    Is this possible? and if so how.

    Wednesday, July 17, 2013 12:20 PM

Answers

  • Hi Ben,

    If that code is not working for you then I guess you must be trying to run it from Slide Show view. If that is the case then you need to modify it to look like this:

    Sub GoToSection()
        Dim ppt As PowerPoint.Presentation
        Dim sldRng As PowerPoint.SlideRange
        Dim sldNbr, secCnt, secNbr As Long
        
        Set ppt = ActivePresentation
        secCnt = ppt.SectionProperties.Count
        If secCnt = 0 Then Exit Sub
        
        If ppt.SlideShowWindow.View.Slide.sectionIndex = secCnt Then
            sldNbr = ppt.SectionProperties.FirstSlide(1)
        Else
            sldNbr = ppt.SectionProperties.FirstSlide(ppt.SlideShowWindow.View.Slide.sectionIndex + 1)
        End If
        ppt.SlideShowWindow.View.GotoSlide sldNbr, msoTrue
    End Sub
    

    This code will only advance to the next section and once it reaches the last section, if the button is pressed again it will return to the first section. If you want to run it in reverse then you will need to create a similar routine that subtracts instead of adds to the section index and you'll need to recode the If statement appropriately so that you don't get into a never ending loop.

    Hope this helps


    Kind Regards, Rich ... http://greatcirclelearning.com

    • Marked as answer by Ben1996 Wednesday, July 24, 2013 2:47 PM
    Wednesday, July 17, 2013 4:03 PM
  • Hi Ben,

    Sure it would look like this:

    Sub GoToPreviousSection()
        Dim ppt As PowerPoint.Presentation
        Dim sldRng As PowerPoint.SlideRange
        Dim sldNbr, secCnt, secNbr As Long
        
        Set ppt = ActivePresentation
        secCnt = ppt.SectionProperties.Count
        If secCnt = 0 Then Exit Sub
        
        If ppt.SlideShowWindow.View.Slide.sectionIndex = 1 Then
            sldNbr = ppt.SectionProperties.FirstSlide(secCnt)
        Else
            sldNbr = ppt.SectionProperties.FirstSlide(ppt.SlideShowWindow.View.Slide.sectionIndex - 1)
        End If
        ppt.SlideShowWindow.View.GotoSlide sldNbr, msoTrue
    End Sub
    


    Kind Regards, Rich ... http://greatcirclelearning.com

    • Marked as answer by Ben1996 Wednesday, July 24, 2013 3:06 PM
    Wednesday, July 24, 2013 3:00 PM

All replies

  • Assign the following code a keystroke or button and it should do what you want.

    Sub GoToSection()
        Dim ppt As PowerPoint.Presentation
        Dim sldRng As PowerPoint.SlideRange
        Dim sldNbr, secCnt, secNbr As Long
        
        Set ppt = ActivePresentation
        secCnt = ppt.SectionProperties.Count
        If secCnt = 0 Then Exit Sub
        
        Set sldRng = PowerPoint.ActiveWindow.Selection.SlideRange
        If sldRng.sectionIndex = secCnt Then
            sldNbr = ppt.SectionProperties.FirstSlide(1)
        Else
            sldNbr = ppt.SectionProperties.FirstSlide(sldRng.sectionIndex) + 1
        End If
        ppt.Slides(sldNbr).Select
    End Sub
    


    Kind Regards, Rich ... http://greatcirclelearning.com

    Wednesday, July 17, 2013 1:58 PM
  • Thank you for this, but it doesn't seem to work.

    I have created a macro using the above and then assigned it to a button. 

    Is there anything I need to edit?

    Also is the code for previous section.

    Kindest Regards, Ben

    Wednesday, July 17, 2013 2:34 PM
  • Hi Ben,

    If that code is not working for you then I guess you must be trying to run it from Slide Show view. If that is the case then you need to modify it to look like this:

    Sub GoToSection()
        Dim ppt As PowerPoint.Presentation
        Dim sldRng As PowerPoint.SlideRange
        Dim sldNbr, secCnt, secNbr As Long
        
        Set ppt = ActivePresentation
        secCnt = ppt.SectionProperties.Count
        If secCnt = 0 Then Exit Sub
        
        If ppt.SlideShowWindow.View.Slide.sectionIndex = secCnt Then
            sldNbr = ppt.SectionProperties.FirstSlide(1)
        Else
            sldNbr = ppt.SectionProperties.FirstSlide(ppt.SlideShowWindow.View.Slide.sectionIndex + 1)
        End If
        ppt.SlideShowWindow.View.GotoSlide sldNbr, msoTrue
    End Sub
    

    This code will only advance to the next section and once it reaches the last section, if the button is pressed again it will return to the first section. If you want to run it in reverse then you will need to create a similar routine that subtracts instead of adds to the section index and you'll need to recode the If statement appropriately so that you don't get into a never ending loop.

    Hope this helps


    Kind Regards, Rich ... http://greatcirclelearning.com

    • Marked as answer by Ben1996 Wednesday, July 24, 2013 2:47 PM
    Wednesday, July 17, 2013 4:03 PM
  • That works a treat thank you Rich. Is there any way of going to the previous section as well. If so what code would I need

    Regards

    Ben

    Wednesday, July 24, 2013 2:46 PM
  • Hi Ben,

    Sure it would look like this:

    Sub GoToPreviousSection()
        Dim ppt As PowerPoint.Presentation
        Dim sldRng As PowerPoint.SlideRange
        Dim sldNbr, secCnt, secNbr As Long
        
        Set ppt = ActivePresentation
        secCnt = ppt.SectionProperties.Count
        If secCnt = 0 Then Exit Sub
        
        If ppt.SlideShowWindow.View.Slide.sectionIndex = 1 Then
            sldNbr = ppt.SectionProperties.FirstSlide(secCnt)
        Else
            sldNbr = ppt.SectionProperties.FirstSlide(ppt.SlideShowWindow.View.Slide.sectionIndex - 1)
        End If
        ppt.SlideShowWindow.View.GotoSlide sldNbr, msoTrue
    End Sub
    


    Kind Regards, Rich ... http://greatcirclelearning.com

    • Marked as answer by Ben1996 Wednesday, July 24, 2013 3:06 PM
    Wednesday, July 24, 2013 3:00 PM
  • One more thing Ben... you do know that PowerPoint has a built-in function that allows the Presenter to skip forward or backward based on Slide Numbers or Section Names?

    While you are running the presentation in the Show Slide view, on the PC...

    A keystroke shortcut of Shift-F10-G brings up a contextual menu with the slides listed by slide number and their Title, as long as one exists on the slide. Select the slide and you go to it immediately.

    A keystroke of Shift-F10-T opens the contextual menu for skipping forward or backward based on Section Name. Selecting one brings you immediately to the first slide of that Section. And just the shortcut of Shift-F10 alone provides the contextual menu for all options available to the presenter.

    On the Mac in PowerPoint 2011 the keystroke shortcut is a Ctrl-Click (AKA right click) on the displayed image. This opens the contextual menu, but unfortunately, even though Sections are supported in Mac PowerPoint 2011, a contextual menu shortcut is not provided so the VBA code would be needed there.


    Kind Regards, Rich ... http://greatcirclelearning.com

    Wednesday, July 24, 2013 3:07 PM
  • Thank you very much Rich

    This is working perfectly

    Regards

    Ben

    Wednesday, July 24, 2013 3:12 PM
  • Hi Rich,

    I knew there was a shortcut but couldnt remember what, but I wanted to assign the next section code to a button. 

    Its easier for the users to press the button than use short cuts.

    Thank you for the extra info though. It's definitely one to rememeber

    Regards

    Ben

    Friday, July 26, 2013 1:26 PM