1

I'm trying to make a choose your own type of game in powerpoint. The game includes a point system that I did using a macro when the user is clicks an option. I also need a hyperlink to jump to the right slide in accordance to the option that was picked.

I tried creating 1 macro for every button, assigning where to slide to jump to, but this becomes solution way too messy since, by the end of the game, there would be hundreds of buttons = hundreds of macro.

Dim numCorrect As Integer
Dim numIncorrect As Integer
Dim userName As String
Dim printableSlideNum As Long 'ADDED
Sub GetStarted()
    Initialize
    ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Initialize()
    numCorrect = 0
    numIncorrect = 0
    ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Right()
    numCorrect = numCorrect + 10
End Sub
Sub Wrong()
    numIncorrect = numIncorrect + 25
End Sub
Sub Feedback()
    MsgBox "You spent " & numCorrect + numIncorrect & " minutes to solve the issue" & vbCr & _
    "Out of the " & numCorrect + numIncorrect & ", you wasted " & numIncorrect & " minutes by choosing the wrong options"
End Sub
Sub JumpTo(lSlideIndex As Long)
    SlideShowWindows(1).View.GotoSlide (lSlideIndex)
End Sub
Sub ONEA()
    Right
    JumpTo 6
End Sub

I had an idea of creating a macro that jumped to a slide number according to the name of the shape, but don't know whether it is possible or not.

Example: option B jumps to slide 60 the shape name would be 60 the vba will match the shape name and jumps to slide 60

Any help/ideas for this is appreciated!

Note: my VBA skills is essentially zero.

1 Answers1

1

To name your shape see How to name an object within a PowerPoint slide?


Sub JumpToSlide(oShp As Shape)

lSlideIndex = CLng(oShp.Name)
SlideShowWindows(1).View.GotoSlide (lSlideIndex)

End Sub

To assign this macro to the shape you can right-click on the shape --> Hyperlink --> Run a Macro --> Select "JumpToSlide"

q0mlm
  • 313
  • 1
  • 3
  • 10