我有一个 vba 脚本,它在演示文稿的幻灯片演示期间运行。在同一张幻灯片上,我有一个动画。运行动画时,脚本“在后台”运行良好,但在动画的某个步骤,我想更改 vba 脚本的运行方式。通过检查时间线对象或其他地方来检查动画已经运行了多远,或者通过在到达正确步骤时触发事件,但我找不到任何东西。
这是我目前的脚本(说明放射源,向各个方向发出辐射)
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Running As Boolean ' Switched on or off by another sub
Sub DrawLines()
Dim endx As Long
Dim endy As Long
Dim Slideid As Long
Dim tetha As Double
Dim origx As Long
Dim origy As Long
Dim linelength As Long
Dim tl As TimeLine
Slideid = 2
origx = 100
origy = 430
linelength = 2000
Dim newline As Shape
While Running
With ActivePresentation.Slides(Slideid).Shapes
tetha = 2 * 3.1415 * Rnd()
endx = Int(linelength * Sin(tetha))
endy = Int(linelength * Cos(tetha))
' Here I want to alter endx and endy after a certain step in the animation
Dim sleeptime As Long
sleeptime = Int(500 * Rnd())
Set newline = .AddLine(origx, origy, endx, endy)
DoEvents ' needed to redraw
Sleep (30)
newline.Delete
DoEvents ' needed to redraw
Sleep (sleeptime)
End With
Wend
End Sub
在我想改变 endx 和 endy 的时候,我一直在寻找类似的东西
IF Activepresentation.slides(slideid).timeline.activestep>=5 THEN
dosomething()
End if
或者如果我可以做类似的东西
Public Changed as boolean
Sub OnSlideShowAnimationStep( .... )
IF currentstep >=5
Changed = TRUE
end if
end sub
然后我可以检查 Drawlines 中的 Changed,但我既找不到任何属性告诉我当前动画步骤,也找不到任何在动画步骤上触发的事件。还有其他我应该看的地方吗?