MENU

1994世界杯_1954年世界杯 - hengshuifu.com

如何在PPT中插入日期和时间并实时更新

你好,靖博唐

欢迎来到微软社区。

可以用VBA来实现:

先在开发工具插入个标签块:

然后Alt+F11插入个模块:

然后输入代码:

Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As Long

Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long

Public mTimer As Long

'计时函数,每一秒钟运行一次

Sub timer()

' 获取当前日期和时间

Dim currentTime As String

currentTime = Format(Now, "yyyy-mm-dd hh:nn:ss")

' 更新幻灯片上的标签显示

Slide1.Label1.Caption = currentTime

End Sub

'1s调用一次timer函数更新当前时间

Sub start()

mTimer = SetTimer(0, 0, 1000, AddressOf timer)

End Sub

'PPT开始展示时,调用start函数,开始显示当前时间

Sub OnSlideShowPageChange()

Call start

End Sub

'PPT终止演示时,结束计时

Sub OnSlideShowTerminate()

mTimer = KillTimer(0, mTimer)

End Sub

然后点击播放即可。

希望以上信息能对您有所帮助。如果您需要进一步帮助,请随时发送信息。

最美好的祝愿

Aiden.C - MSFT |微软社区支持专家

Copyright © 2022 1994世界杯_1954年世界杯 - hengshuifu.com All Rights Reserved.