Last active
December 1, 2019 08:20
-
-
Save ivanelianto/622c5ad8f73a146a86ead8c95e309c9d to your computer and use it in GitHub Desktop.
Random Power Point Slide Without Repetition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim NotShownSlideIndexes As New Collection | |
Dim HasStarted As Boolean | |
Sub OnSlideShowPageChange() | |
If HasStarted = False Then | |
HasStarted = True | |
Set NotShownSlideIndexes = Nothing | |
For Each Slide In ActivePresentation.Slides | |
With Slide.Shapes(2).ActionSettings(ppMouseClick) | |
.Action = ppActionRunMacro | |
.Run = "ShowRandomSlide" | |
End With | |
NotShownSlideIndexes.Add Slide | |
Next | |
NotShownSlideIndexes.Remove 1 | |
End If | |
End Sub | |
Sub OnSlideShowTerminate(SW As SlideShowWindow) | |
HasStarted = False | |
End Sub | |
Sub ShowRandomSlide() | |
If NotShownSlideIndexes.Count > 0 Then | |
Dim SelectedSlideIndex As Integer | |
Randomize | |
SelectedSlideIndex = Int(Rnd * NotShownSlideIndexes.Count) + 1 | |
ActivePresentation.SlideShowWindow.View.GotoSlide NotShownSlideIndexes(SelectedSlideIndex).SlideIndex | |
NotShownSlideIndexes.Remove SelectedSlideIndex | |
Else | |
HasStarted = False | |
ActivePresentation.SlideShowWindow.View.Exit | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment