T
TeacherValerie
I am a teacher created a game for my students I plan to use next week....
I found a post from David and am trying to use it but it is not working. I
want to randomize slides 2-26 in my presentation. So I created a button on
the first page that links to the GetStarted macro and a button on the 2nd
page that links to the GoToRandom macro.
When I added it, it automatically created 3 macros for me (the 3rd being
Initialize). Can you tell me if there is a mistake in my code (see below)?
THANKS!!!!!!!!!!!!!!!!!
Valerie
Sub GetStarted()
Dim doneSlide(6) As Boolean
Sub GetStarted()
Initialize
GoToRandom
End Sub
Sub Initialize()
Dim i As Long
For i = 2 To 26
doneSlide(i) = False
Next i
End Sub
Sub GoToRandom()
Dim nextSlide As Long
Randomize
If doneSlide(2) And doneSlide(3) And doneSlide(26) And doneSlide(5) Then
ActivePresentation.SlideShowWindow.View.GotoSlide 6
Else
nextSlide = Int(Rnd * 26) + 2
While doneSlide(nextSlide)
nextSlide = Int(Rnd * 26) + 2
Wend
doneSlide(nextSlide) = True
ActivePresentation.SlideShowWindow.View.GotoSlide nextSlide
End If
End Sub
Just set the button on your first slide to GetStarted and a button on slides
2, 3, 4, and 5 to GoToRandom
End Sub
I found a post from David and am trying to use it but it is not working. I
want to randomize slides 2-26 in my presentation. So I created a button on
the first page that links to the GetStarted macro and a button on the 2nd
page that links to the GoToRandom macro.
When I added it, it automatically created 3 macros for me (the 3rd being
Initialize). Can you tell me if there is a mistake in my code (see below)?
THANKS!!!!!!!!!!!!!!!!!
Valerie
Sub GetStarted()
Dim doneSlide(6) As Boolean
Sub GetStarted()
Initialize
GoToRandom
End Sub
Sub Initialize()
Dim i As Long
For i = 2 To 26
doneSlide(i) = False
Next i
End Sub
Sub GoToRandom()
Dim nextSlide As Long
Randomize
If doneSlide(2) And doneSlide(3) And doneSlide(26) And doneSlide(5) Then
ActivePresentation.SlideShowWindow.View.GotoSlide 6
Else
nextSlide = Int(Rnd * 26) + 2
While doneSlide(nextSlide)
nextSlide = Int(Rnd * 26) + 2
Wend
doneSlide(nextSlide) = True
ActivePresentation.SlideShowWindow.View.GotoSlide nextSlide
End If
End Sub
Just set the button on your first slide to GetStarted and a button on slides
2, 3, 4, and 5 to GoToRandom
End Sub