我正在尝试使用VBA创建PowerPoint随机选择器幻灯片。我设法做到了,但是它显示了下一个选择的结果。延迟4张幻灯片后,有什么方法可以停止吗?诸如“幸运抽奖”之类的结果导致缓慢的停止?
这是我的代码:
Sub randjump()
Randomize
Dim Inum As Integer
Inum = Int(7 * Rnd + 4)
ActivePresentation.SlideShowWindow.View.GotoSlide (Inum)
End Sub
我也尝试使用其他代码,但是名称列表出现问题。我不确定如何从列表中构成数据数组?
我正在尝试在PowerPoint Shape
上而不是在MsgBox
上显示结果,但是不确定这是否也会产生运行中的随机名称效果并缓慢停止...
Sub From_Hat()
'Declare the collection
Dim myHat As New Collection
Dim names() As String
Dim x As Long
Dim iChoice As Integer
names = Split("Bob\Mary\Joe\John", "\")
For x = 0 To UBound(names)
myHat.Add (names(x))
Next x
Do
Randomize
'choose a random name
iChoice = Int(Rnd * myHat.Count) + 1
MsgBox myHat(iChoice)
'remove that choice
myHat.Remove (iChoice)
Loop Until myHat.Count = 0
MsgBox "All chosen"
End Sub
'load into the new collection
For x = 1 To 99
myHat.Add (x)
Next x
End Sub