How to jump to a RANDOM SLIDE in PowerPoint using VBA

preview_player
Показать описание
--------------------------------------------------------------------------
Sub GotoRandomSlide()
FirstSlide = 2
LastSlide = 7
Randomize
'generate a random no between first slide and last slide'
GRN:
RSN = Int((LastSlide - FirstSlide + 1) * Rnd + FirstSlide)
If RSN = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex Then GoTo GRN
ActivePresentation.SlideShowWindow.View.GotoSlide (RSN)
End Sub
--------------------------------------------------------------------------
How to be redirected or hyperlinked to a random slide in PowerPoint using Visual Basic Code.

In our module, we have six different slides containing unique names from A to F. I need to be redirected to any one of those slides randomly on the press of a button.

I also need to make sure that I am not being redirected to the same slide consecutively in the case that the same random number is again generated.

So now, let us shuffle our slides and get hyperlinked to a random slide in Microsoft PowerPoint.

*RND Function & Randomize Function in VBA*
RND function in Visual Basic Application generates a random number of the data type Single which is less than 1 but greater than or equal to 0.

Remember to use the Randomize Function before using the RND Function. The Randomize Function makes the order of the random numbers generated random.

There are many sequences or orders to generate pseudo-random numbers via VBA which are called seeds.

For any given initial seed, the same number sequence is generated because each successive call to the Rnd function uses the previous number as a seed for the next number in the sequence.

Before calling Rnd, use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer.

*Generating a random integer between a given range in VBA*
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

Here, upperbound is the highest number in the range, and lowerbound is the lowest number in the range.

--

Music by Ashwin Subrahm and Distant Lakey Inspired

I also do freelancing, contact me:
Bhavesh Shaha,
Рекомендации по теме
Комментарии
Автор

Hi! On Slideshow inside the project this works, but when I export on .ppsm on kiosk mode to have it full screen like a videogame it doesn't work. Any help?

Netmicha
Автор

I'm a novice. I feel like I missed something @1:43. Did you jump to Slide 3? Where is the code being entered to? The same macro?

liamsu
Автор

Where is the link for the video explaining how to jump to a random slide that does not repeat? It was mentioned at the end of the video.

demonapiccolo
Автор

Hi!

How can I shuffle slides but only for odd or even slide numbers?

Let's say... slides 1, 3, 5, 7 to 3, 7, 5, 1 / or slides 2, 4, 6, 8 to 8, 4, 2, 6

anhelloooo
Автор

Excellent video as usuall. So, how can we show the names only once to avoid repeating the names. Thanks

batisbat
Автор

So what if i want to jump a random slide 2 times and then go back to the first slide ?

sleepyshinra
Автор

thank you for this video
I have a question
please how to display random picture by clicking command button
thank for your help

chaimaeghan
Автор

Hello. I must be doing something wrong. I followed the guide. But when I hit run it tells me.
There is currently no slide show view for this presentation.
Can you tell me what I'm doing wrong ??

ookii
Автор

how can you random slides and limit only to 10 from 100?

geraldalgunas
Автор

Can you random slide only from 10 to 20?

NgaNguyen-trbs