1

I am trying to advance slides based on a response. I want to go forward 2 slides if the user selects easy and one if they select hard. This is my current code. The Nextpage script isn't working AND I would prefer for it to be usable for multiple questions--I can't seem to get it to work with something like slide +1 or slide +2 (or ++).

Sub Start()
    ActivePresentation.Slides(2).Shapes("selection_hard").Visible = False
    ActivePresentation.Slides(2).Shapes("selection_easy").Visible = False

    ActivePresentation.SlideShowWindow.View.Next
End Sub


Sub Shoe_Easy()
    ShoeAnswer = "Easy"

    ActivePresentation.Slides(2).Shapes("selection_hard").Visible = False
    ActivePresentation.Slides(2).Shapes("selection_easy").Visible = True

    'ActivePresentation.SlideShowWindow.View.GotoSlide (11)
End Sub



Sub Shoe_Hard()
    ShoeAnswer = "Hard"

    ActivePresentation.Slides(2).Shapes("selection_hard").Visible = True
    ActivePresentation.Slides(2).Shapes("selection_easy").Visible = False

    'ActivePresentation.SlideShowWindow.View.GotoSlide (12)
End Sub


Sub Nextpage()
    If ActivePresentation.Slides(2).Shapes("selection_hard").Visisble = True Then
        ActivePresentation.SlideShowWindow.View.GotoSlide (3)

    ElseIf ActivePresenation.Slides(2).Shapes("selection_easy").Visible = True Then
        ActivePresenation.SlideShowWindow.View.GotoSlide (4)
    End If
End Sub

2 Answers 2

1

Assuming that "response" means clicking on one of two shapes (Easy or Hard), this will do it. You just need to make sure that the text in the shape and the code below match up and that you assign the HandleClick macro as a RunMacro action setting to each of the shapes (assign them to two of them then copy/paste the shapes elsewhere as needed).

There are a few extra hoops to jump through to get this working on a Mac; shout if you need it to work there too.

Sub HandleClick(oSh As Shape)

    ' Did they click the Easy or Hard button?
    ' oSh contains a reference to the shape they clicked
    ' Look a the text in oSh to decide where to go next:

    Select Case UCase(oSh.TextFrame.TextRange.Text)
        Case Is = "EASY"
            SlideShowWindows(1).View.GotoSlide (oSh.Parent.SlideIndex + 2)
        Case Is = "HARD"
            SlideShowWindows(1).View.GotoSlide (oSh.Parent.SlideIndex + 1)
        Case Else
            ' Do nothing
    End Select

End Sub

This immediately advances the slide as soon as it's clicked. If you want the user to be able to choose an answer and then advance, you'd need a different approach.

Instead of advancing immediately as above, you'd set the value of a global variable to, say, "EASY" or "HARD", depending on the user's selection.

Then in a separate macro assigned to your forward button, you'd advance one or two slides depending on the value of the global variable.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! So, the object that says "easy" in it, when clicked is linked to run Shoe_Easy(), the "hard" one is linked to Shoe_Hard(). I'm confused about what the "Case Is" is referring to. Why do I not have to link it some statement, like Case Is = ShoeAnswer = "easy"? Is that b/c of the oSh? Also, the shape says "easy," but I did not link an action to the text, only the shape. Also, I realize that this will automatically advance the slides. I want this macro to go on a different button--the forward arrow, so users can switch answers if they want before progressing. Thanks!!!
Yes; as written, when the user clicks the shape with "Easy" in it, it advances 2 slides, which is what you asked for. It could instead call another subroutine if you wish. Read the docs for Select Case for an explanation of how it works and the edited version of the example above for more comments. The macro can be assigned to any shape you like.
0

I think something like this might help:

Nextpage()
Dim currentSlide as Slide
Set currentSlide = ActivePresentation.SlideshowWindow.View.Slide

    If ActivePresentation.Slides(2).Shapes("selection_hard").Visisble = True Then
        ActivePresentation.SlideShowWindow.View.GotoSlide currentSlide.SlideIndex + 1

    ElseIf ActivePresenation.Slides(2).Shapes("selection_easy").Visible = True Then
        ActivePresenation.SlideShowWindow.View.GotoSlide currentSlide.SlideIndex + 2
    End If
End Sub

4 Comments

So for this one, for the ElseIf statement, would I actually need to say +2?
Thank you. No unfortunately it did not. Do you have any ideas why?
No, the button doesn't do anything. Thanks!
What is your question, then? I had to assume that your original sub NextPage was already working -- but instead of always going to slide 3 or 4, you needed to make that variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.