filmov
tv
How to jump to a RANDOM SLIDE in PowerPoint using VBA
Показать описание
--------------------------------------------------------------------------
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,
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,
Комментарии