random slides

C

Charles Dapper

How can I show presentation slides in random order rather than in sequence?
I have PowerPoint 2002.



Thanks,

Chuck
 
C

Charles Dapper

Thanks for the link. I tried to follow the instructions but couldn't get
random slides to work yet. I'll keep trying.



Thanks,

Chuck
 
T

TAJ Simmons

Chuck,

You may have to 'lower' your security settings in powerpoint to get the
'code/macro' to run

cheers
TAJ
 
D

David Marcovitz

Don't forget to lower your security settings, close the PPT and reopen
it. If you don't close the PPT, the new security settings won't apply to
the open PPT until it is closed and reopened.
--David
 
C

Charles Dapper

I did that too but no success.



Chuck



David Marcovitz said:
Don't forget to lower your security settings, close the PPT and reopen
it. If you don't close the PPT, the new security settings won't apply to
the open PPT until it is closed and reopened.
--David

--
David Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
C

Charles Dapper

I don't get any error messages. Here's what I did.



Set macro security to medium.

Closed Powerpoint.

Opened Powerpoint.

Opened Visual Basic editor.

Clicked insert - module.

Copied/ pasted

Private Sub CommandButton1_Click()

ActivePresentation.SlideShowWindow _

View.GotoSlide Int(Rnd * _

ActivePresentation.Slides.Count) + 1

End Sub (from http://www.pptfaq.com/FAQ00429.htm)

Created action button.

Clicked action settings - macro.

And then nothing happens.



I tried the same with

Sub sort_rand()

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

End Sub



I can assign that to an action button, unlike the first one, but then
nothing happens when I click the button.



Thanks,

Chuck
 
D

David Marcovitz

Aha. Now it is all clearer. To use the first code, you need to create a
command button using the control toolbox. Double click on the command
button. It should open a module in the VBA editor automatically. In the
code below, copy and paste everything between the "Private Sub" and "End
Sub" lines between similar lines in your module. If you do that,
clicking on your button (in slide show view) should work).

To use the second set of code, you need to run that in Normal view not
slide show view. You can put that in a module. Then, while in Normal
view, hit Alt-F8 and choose to run the macro named sort_rand.

--David
 
C

Charles Dapper

Thanks. I'll try that.
Chuck

David Marcovitz said:
Aha. Now it is all clearer. To use the first code, you need to create a
command button using the control toolbox. Double click on the command
button. It should open a module in the VBA editor automatically. In the
code below, copy and paste everything between the "Private Sub" and "End
Sub" lines between similar lines in your module. If you do that,
clicking on your button (in slide show view) should work).

To use the second set of code, you need to run that in Normal view not
slide show view. You can put that in a module. Then, while in Normal
view, hit Alt-F8 and choose to run the macro named sort_rand.

--David

--
David Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
C

Charles Dapper

Thanks again. I tried the code but don't know how to use it for my project.



I'm trying to create a classroom quiz. Only a few slides, for instance slide
10 through 30, have to appear at random. The others have to remain in their
original sequence.



How can I do that?



Thanks,

Chuck
 
D

David Marcovitz

OK. Here is some code that should work for you. What you need to do is
paste this into a new module. Then you need to adjust the startRandom
and endRandom lines (just change the numbers on those lines to be the
first/last slide you want randomized--such as 10 and 30). Now, in your
presentation, make some buttons:

* a button on the slide that takes you to the first random slide
(probably slide 9 for you) that runs the procedure GetStarted.
* a button on each of the random slides that runs the procedure
RandomNext.

Note that this is code I modified from Example 8.16 on my Web site
(http://www.PowerfulPowerPoint.com/).

Dim visited() As Boolean
Dim numSlides As Long
Dim numRead As Integer
Dim startRandom As Integer
Dim endRandom As Integer

Sub GetStarted()
Initialize
RandomNext
End Sub

Sub Initialize()
Randomize
numRead = 0
startRandom = 3 'set this to the first slide # you want randomized
endRandom = 9 'set this to the last slide # you want randomized
numSlides = endRandom - startRandom + 1
ReDim visited(numSlides)
For i = 0 To numSlides
visited(i) = False
Next i
End Sub


Sub RandomNext()
Dim nextSlide As Long

If numRead >= numSlides Then
ActivePresentation.SlideShowWindow.View.Last
Else
nextSlide = Int((numSlides) * Rnd)
While visited(nextSlide) = True
nextSlide = Int((numSlides) * Rnd)
DoEvents
Wend
numRead = numRead + 1
visited(nextSlide) = True
ActivePresentation.SlideShowWindow.View.GotoSlide _
nextSlide + startRandom
End If
End Sub
 
C

Charles Dapper

Thank you. That will take me some time. I will try it and also have a look
at your web site.



Thanks again,

Chuck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top