A family of Microsoft presentation graphics products that offer tools for creating presentations and adding graphic effects like multimedia objects and special effects with text.
Put a DoEvents statement inside the loop.
In 2010 the screen refresh lines should not be needed.
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub WhereSheStopsNobodyKnows()
' Only works in slideshow mode.
'
Dim sld As Slide
Dim shpRng As ShapeRange
Dim shp As Shape
Dim lnMin As Long, lnMax As Long, i As Long, lnRand As Long, lnPrev As Long
Dim ssw As SlideShowWindow
'Random = Int((lnMax - (lnMin - 1)) * Rnd) + lnMin
lnMin = 1
lnMax = 4
'Check we are in slideshow mode:
On Error Resume Next
Set ssw = ActivePresentation.SlideShowWindow
On Error GoTo 0
If ssw Is Nothing Then
Exit Sub
Else
Set sld = ssw.View.Slide
End If
Set shpRng = sld.Shapes.Range(Array("Rectangle 1", "Rectangle 2", "Rectangle 3", "Rectangle 4"))
For i = 1 To 30
Do
Randomize
lnRand = Int((lnMax - (lnMin - 1)) * Rnd) + lnMin 'get rand num.
Loop While lnRand = lnPrev 'make sure rand num is different from previous rand num
lnPrev = lnRand
Sleep 100 '0.1s delay
shpRng.Fill.ForeColor.RGB = RGB(0, 0, 255) 'set all shapes to blue
sld.Shapes("Rectangle " & lnRand).Fill.ForeColor.RGB = RGB(255, 255, 0) 'set a random shape to yellow
DoEvents
' 'Refresh the slide: (Not needed in 2010??)
ssw.View.GotoSlide (sld.SlideIndex)
Set shp = sld.Shapes.AddLine(0, 0, 0, 1)
shp.Delete
Next i
End Sub