Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Possible to randomize some slides, not all?

842 views
Skip to first unread message

Preschool Mike

unread,
Jul 1, 2009, 10:23:01 AM7/1/09
to

Is it possible to randomize only some of the slides in my presentation?
My slideshow/game may have up to 60 slides. Slide 1 is my
welcome/directions slide. What I'd like to have happen is for slide 1 to
randomly take my player to either slides 2, 3, 4, or 5. From here I will use
traditional powerpoint links to advance the slideshow/game. I don't want
slides 6 and on to appear in random order.

Basically what I'm trying to accomplish by doing it this way is to have four
games in one presentation (the same game with different result). These four
slides look exactly the same in appearance. I don't want my player to
realize which slide they are on so each time the game is played it's
different. I've found two codes that randomize the every slide but only want
to randomize some. Can I modify these to suit my needs? If so how? Or do I
need something entirely different?

First method:
ActivePresentation.SlideShowWindow_
.View.GotoSlide Int(Rnd * _
ActivePresentation.slides.Count) + 1

Second method:
Dim i As Integer
Dim myvalue As Integer
Dim islides As Integer
islides = ActivePresentation.Slides.Count
For i = 1 To ActivePresentation.Slides.Count
myvalue = Int((i * Rnd) + 1)
ActiveWindow.ViewType = ppViewSlideSorter
ActivePresentation.Slides(myvalue).Select
ActiveWindow.Selection.Cut
ActivePresentation.Slides(islides - 1).Select
ActiveWindow.View.Paste
Next

Am more than willing to buy the add-in from
(http://www.tushar-mehta.com/powerpoint/randomslideshow/), but want to learn
how to do this on my own.

thanks,

Mike

David Marcovitz

unread,
Jul 1, 2009, 10:58:28 AM7/1/09
to

Mike,

This should be very easy because all you want to do is randomly choose
slides 2, 3, 4, or 5. Is that correct? That is, you want to jump to one of
those slides and then after that jump to slide 6. Or do you want to go
through slides 2, 3, 4 and 5 in random order and then go to slide 6. That
would be a little harder but not too difficult.

Just to jump to one random slide would be something like:

Sub GoToRandom2345()
Dim nextSlide As Long
Randomize
nextSlide = Int(Rnd * 4) + 2
ActivePresentation.SlideShowWindow.View.GotoSlide nextSlide
End Sub

The hard part about going through those slides in random order is simply
keeping track of which ones you have been two. The simplest way is something
like this:

Dim doneSlide(6) As Boolean

Sub GetStarted()
Initialize
GoToRandom
End Sub

Sub Initialize()
Dim i As Long

For i = 2 To 5
doneSlide(i) = False
Next i
End Sub

Sub GoToRandom()
Dim nextSlide As Long

Randomize
If doneSlide(2) And doneSlide(3) And doneSlide(4) And doneSlide(5) Then
ActivePresentation.SlideShowWindow.View.GotoSlide 6
Else
nextSlide = Int(Rnd * 4) + 2
While doneSlide(nextSlide)
nextSlide = Int(Rnd * 4) + 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.

--David

On 7/1/09 10:23 AM, in article
B56FE6C3-F208-4E10...@microsoft.com, "Preschool Mike"
<Presch...@discussions.microsoft.com> wrote:

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland


Preschool Mike

unread,
Jul 1, 2009, 11:35:38 AM7/1/09
to

Thanks David
Your first example seems to be the one I need. Just a couple of other
questions for future reference. If I wanted to change it to be slides 2 - 10
(for example) would I change nextSlide = Int(Rnd * 4) + 2 to nextSlide =
Int(Rnd * 9) + 2? And does this code follow the slide name or slide order?
Just in case in the future I add another slide between Slide 1 and Slide 2
(e.g., now slide 2 is actually slide 20). Would doing this mess things up
for me?

John Wilson

unread,
Jul 1, 2009, 11:33:53 AM7/1/09
to

As well as David's code there is code here to shuffle a section of slides
which might help. Use a copy because unshuffle is not so easy!
http://www.pptalchemy.co.uk/vbasamples.html
--
john ATSIGN PPTAlchemy.co.uk
Custom vba coding and PPT Makeovers
Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html

David Marcovitz

unread,
Jul 1, 2009, 11:47:10 AM7/1/09
to

The formula (from memory so I hope it is right) is:

Int(Rnd * <number of slides>) + <start slide>

Thus, if you want to randomly select from 100 slides, you would change the 4
to 100. If you want the first random slide to be slide 17, you would change
the 2 to 17. No names are involved here; it is all used SlideIndex. To do
this with names would add a whole new level of complexity...although I
suppose if the first slide in your list of random slides is named (say,
FirstRandom), you could easily use:

nextSlide = Int(Rnd * 4) +

ActivePresentation.Slides("FirstRandom").SlideIndex

On 7/1/09 11:35 AM, in article
C1B0A806-C4D8-4CB8...@microsoft.com, "Preschool Mike"

Preschool Mike

unread,
Jul 1, 2009, 12:04:48 PM7/1/09
to

This works great as well.

Thanks so much,

Mike

Anas

unread,
Feb 10, 2010, 9:26:01 AM2/10/10
to
I have solution that does not require coding:
1. You can draw a square (or a shape that fits a button) using the toolbar
tools then choose no fill for the color of the square can be stretched to
fill the screen (to click any where) or can be stretched into a size of a
button. After you have the invisible square get another invisible square the
square (and you make get multiple squares) assign for each square a hyper
link that leads to a specific slide by right clicking it and clicking on
action settings and then click then click the arrow select slide... then
select a slide from a given list of slides. After you assigned a link to each
invisible square right click the forefront square and click Custom Animation
animate the square to flicker or flash so that every time the square
disappears as it flicks the square behind it will be exposed to being clicked
in a 1/2 chance of the time and forefront square gets the other 1/2.

2. Another way to make randomness is to stretch invisible squares to fill a
clicked area with each square filling a different area of the area to be
clicked. Assign a hyper-link to each square and make the squares taking
almost the same fraction of the space to be clicked to maximize randomness.

Anas

unread,
Feb 10, 2010, 9:58:12 AM2/10/10
to
0 new messages