PDA

View Full Version : My Code doesn't work



tonton
12-11-2018, 06:15 AM
I have the following code that is intended to generate non-repeating random numbers as many as my slides and then go to the random slide after a click. I'd like to add a button to the last slide to end the slide show if possible. This has to be floating because if it is displayed at random, who knows which the last slide is. Anyway, that's secondary but my code seems to work during debug but when I run it, the action button does nothing beginning from the first page. I will appreciate any help. Thanks

Dim dupSlide As Boolean
Public curSlide(10) As Integer
Public numOfSlides As Integer
Public k As Integer


Sub flipSlids()
With ActivePresentation.Slides
' If SSW.Presentation.SlideShowSettings.StartingSlide Then
numOfSlides = .Count
End With
Randomize
For i = 1 To numOfSlides - 1
100 dupSlide = False
curSlide(i) = Int(numOfSlides * Rnd) + 1
If i > 1 Then
For j = 1 To i - 1
If curSlide(i) = curSlide(j) Then
dupSlide = True
End If
Next
End If
If dupSlide = True Then
GoTo 100
' ActivePresentation.SlideShowWindow.View.GotoSlide (curSlide(i))
End If
Next
k = 1
' ActivePresentation.SlideShowWindow.View.GotoSlide (curSlide(k))
Call shwSlides

End Sub


Sub shwSlides()
If curSlide(k) <> 1 Then
ActivePresentation.SlideShowWindow.View.GotoSlide (curSlide(k))
End If
k = k + 1
End Sub

John Wilson
12-12-2018, 06:45 AM
Here an alternative approach for you to consider.

23398

tonton
12-12-2018, 08:21 PM
Here an alternative approach for you to consider.

23398


This is great John. It works great, and thank you so much. I was a little short sighted. I got frustrated when my code wasn't working and I sought help right away. What I really want to do is have them work in pairs like a question and answer pair and I have to keep track of the pair so that I don't give wrong answers to the questions. I am not sure where to tweak your code to get the desired goal. I you can help me further, it will be so great.
Thanks a lot.
tonton