我试图在 MS Powerpoint 中实现的是一个数字计数器,它可以在多张幻灯片上计数到一个预先确定的数字,即从 1 到 1000,如果由于过度运行而在幻灯片放映结束之前达到了这个数字,它只会在演讲结束的幻灯片上显示 1000。
到目前为止,我发现了一些从 60 倒数到 0 的代码,但只在一张幻灯片上,我试图以此为基础,但由于我缺乏对 VBA 和 powerpoint 的理解,到目前为止还没有运气。
任何帮助将不胜感激。
以下是仅适用于下面一张幻灯片的倒计时代码:
Sub Time_Me2()
Dim oshp As Shape
Dim oshpRng As ShapeRange
Dim osld As Slide
Dim oeff As Effect
Dim i As Integer
Dim Iduration As Integer
Dim Istep As Integer
Dim texttoshow As String
On Error GoTo errhandler
If ActiveWindow.Selection.ShapeRange.Count > 1 Then
MsgBox "Please just select ONE shape!"
Exit Sub
End If
Set osld = ActiveWindow.Selection.SlideRange (1)
Set oshp = ActiveWindow.Selection.ShapeRange(1)
oshp.Copy
'change to suit
Istep = 1
Iduration = 60 'in seconds
For i = Iduration To 0 Step -Istep
Set oshpRng = osld.Shapes.Paste
With oshpRng
.Left = oshp.Left
.Top = oshp.Top
End With
texttoshow = CStr(i)
oshpRng(1).TextFrame.TextRange = texttoshow
Set oeff = osld.TimeLine.MainSequence _
.AddEffect(oshpRng(1), msoAnimEffectFlashOnce, , msoAnimTriggerAfterPrevious)
oeff.Timing.Duration = Istep
Next i
oshp.Delete
Exit Sub
errhandler:
MsgBox Err.Description
End Sub
任何帮助都会很棒!