|
Sub txtStart()
For i = 1 To 5000
With ActivePresentation.Slides(1)
For j = 1 To 1
With .Shapes("txtNum" & j).TextFrame.TextRange
.Text = Int((300 - 1 + 1) * Rnd + 1)
.Font.Color.RGB = 10000 * Rnd
Debug.Print .Text
End With
Next
End With
DoEvents
Next
End Sub
Sub OnSlideShowTerminate()
Exit For
End Sub
这是网上找的一段PPT随机抽奖程序,我稍加修改如下:
Sub txtStart()
Dim a() As String
Dim i As Integer
Dim x As Integer
Open "高一名单.txt" For Input As #1
Do Until EOF(1)
i = i + 1
ReDim Preserve a(i) As String
Line Input #1, a(i)
Loop
For x = 1 To 5000
With ActivePresentation.Slides(1)
For j = 1 To 1
With .shapes("txtNum" & j).TextFrame.TextRange
.Text = a(Int(57 * Rnd + 1))
.Font.Color.RGB = 10000 * Rnd
Debug.Print .Text
End With
Next
End With
DoEvents
Next
End Sub
Sub OnSlideShowTerminate()
Exit For
End Sub
运行后名单能跑起来,但点停止后就不能再运行了,为啥?请高手指点,我对VBA一窍不通。
|
|