首页 > 解决方案 > OnSlideShowPageChange 不推进幻灯片

问题描述

我正在尝试在信息亭的 PowerPoint 演示文稿中的每张幻灯片上运行实时时钟。

我能够让实时时间以第一张幻灯片上的首选格式完美运行。幻灯片不会前进。手动高级时,宏不会在第二张幻灯片上运行。这是我的代码。

似乎代码覆盖了默认的幻灯片设置?

Sub OnSlideShowPageChange()
Dim i As Integer
Dim time As Date

time = Now()
time = DateAdd("n", minutes, time)
i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition

Do
DoEvents

With ActivePresentation.Slides(i).Shapes("Rectangle 3").TextFrame.TextRange
    .Text = Format(Now(), "hh:mm:ss")
End With
Loop
End Sub

标签: vbapowerpoint

解决方案


我发现幻灯片不会前进,因为我被困在循环中。这是我的解决方案……但它的成功是零星的。有时它会滚动 5 张幻灯片,然后卡在一张幻灯片上,有时 2 张。我不确定发生了什么。仍在挖掘它。

Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
Dim i As Integer
Dim time As Date
Dim tstop As Date

time = Now()
time = DateAdd("n", minutes, time)
tstop = time + TimeValue("00:00:10")
i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition

Do Until time = tstop
DoEvents

With ActivePresentation.Slides(i).Shapes("Rectangle 3").TextFrame.TextRange
    .Text = Format(Now(), "hh:mm:ss AM/PM")
End With

time = Now()
Loop
End Sub

推荐阅读