"Days Since Last..." VBA PowerPoint 幻灯片更新

"Days Since Last..." VBA PowerPoint Slide Update

我的第一个 post,如果我在这里遗漏了一些明显的东西,或者无意中重复了最近已解决的问题,我深表歉意。

所以我正在用 PowerPoint 2016 制作演示文稿:

我想做什么:

因此位置 28 的幻灯片是 "Days Since Last Lost-Time Accident" 幻灯片。

我用于更新文本框的宏 如果手动触发, 会很漂亮,我 post 这部分让您可以准确地看到我试图触发的内容。

Sub Countup()
Dim thedate As Date
Dim daycount As Long
Dim Icount As Integer
ActivePresentation.Slides(28).Shapes("LTAno").Select
thedate = "10/04/2017"
daycount = DateDiff("d", thedate, Now)
ActivePresentation.Slides(28).Shapes("LTAno").TextFrame.TextRange.Text = daycount
End Sub

这上面-(这两部分在一个模块中)-是问题代码:

Public Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = 28 Then
Call Countup
End If
End Sub

我使用消息框检查以确保幻灯片 28 确实是幻灯片 28,并且弹出没有问题。所以我将 msgbox 行更改为 CALL 函数。

我想这就是我的问题所在?我的头很痛......谁能指出我正确的方向? :)

无论我如何启动幻灯片,幻灯片上的数字都不会更新,除非我手动触发宏。

不要"select"形状。例如:

Sub Countup()
    Dim thedate As Date
    Dim daycount As Long
    Dim Icount As Integer
    Dim vShape 
    Set vShape = ActivePresentation.Slides(28).Shapes("LTAno")
    thedate = "10/04/2017"
    daycount = DateDiff("d", thedate, Now)
    vShape.TextFrame.TextRange.Text = daycount
End Sub