View Single Post
 
Old 01-06-2015, 10:40 PM
PolarisTLX PolarisTLX is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Jan 2015
Posts: 1
PolarisTLX is on a distinguished road
Question Macros to select random odd numbered slide

Trying to create random flash cards using power point.

I think I almost have the code right. I only need a slight modification to it.


Slide 1 is question. Slide 2 is Answer. All odd numbered slides are questions and their subsequent answer is the next slide.

After seeing an answer (even numbered slide) I would place a link that runs the macros which picks the next random question (odd numbered slide).

So I would just need a macros that chooses another random odd numbered slide. That number should also be less then the total number of slides.



I think I almost have it working from an example I found that is loosely similar but it doesn't quite work perfectly. This is what I have so far:

Dim visited() As Boolean
Dim numSlides As Long
Dim numRead As Integer
Dim numWanted As Integer
Sub Initialize()
Randomize
numWanted = 5
numRead = 0
numSlides = ActivePresentation.Slides.Count
ReDim visited(numSlides)
For i = 2 To numSlides - 1
visited(i) = False
Next i
End Sub
Sub RandomNext()
Dim nextSlide As Long

If numRead >= numWanted Or numRead >= numSlides - 2 Then
ActivePresentation.SlideShowWindow.View.Last
Else
nextSlide = Int((numSlides - 2) * Rnd + 2)
While visited(nextSlide) = True
nextSlide = Int((numSlides - 2) * Rnd + 2)
Wend
ActivePresentation.SlideShowWindow.View.GotoSlide nextSlide
End If
End Sub


Anyone know what I need to change or have a better code for this?

Thank you very much.
Reply With Quote