vba - 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
解决方案
我发现幻灯片不会前进,因为我被困在循环中。这是我的解决方案……但它的成功是零星的。有时它会滚动 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
推荐阅读
- c# - C# 用 SQLite,real 带逗号的值怎么弄?
- python - 带有 Flask 的 pyCUDA 给出 pycuda._driver.LogicError: cuModuleLoadDataEx
- spring - HTTP 出站网关 - uri 变量 - 编码
- stenciljs - 为类型配置 baseUrl:dist
- xamarin - Xamarin Forms MasterDetailPage 选择器在导航之间重置
- javascript - Ajax 结果页面无法读取 Host 的脚本
- datetime - 如何在 Sequelizejs 中存储 ISO 8601 日期时间
- unity3d - 构建 System.Serializable 类时不支持的类型
- java - 无法在 Spock 测试中使用不可变 DTO
- javascript - 使用 HTML 表单中的 XHttpRequest 更改 HTML 元素