我使用此代码在 PowerPoint 中跨多张幻灯片进行了倒计时:
Global time As Date
Sub countdown()
time = Now()
time = DateAdd("n", 10, time)
Do Until time < Now()
DoEvents
ActivePresentation.SlideShowWindow.View.Slide.Shapes("countdown").TextFrame.TextRange = Format((time - Now()), "nn:ss")
Loop
End Sub
倒计时在幻灯片 2 到 5 上,我希望它在幻灯片 2 出现时自动开始。
有人可以帮助我吗? 谢谢
我对 vba 不太了解,所以我尝试在互联网上找到解决方案,但是......
将其添加到 ThisPresentation 模块中:
Private Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.Slide.SlideIndex = 2 Then Call countdown
End Sub
然后你需要用这个修改你的子:
Sub countdown()
Dim time As Date: time = DateAdd("n", 10, Now)
Do Until time < Now()
DoEvents
ActivePresentation.SlideShowWindow.View.Slide.Shapes("countdown").TextFrame.TextRange.Text = Format((time - Now()), "nn:ss")
Loop
End Sub