美文网首页
使用VBA实现高考倒计时PPT

使用VBA实现高考倒计时PPT

作者: 麦睿蔻 | 来源:发表于2020-05-05 18:50 被阅读0次

    用VBA实现了个高考倒计时的PPT,代码如下:

    Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    Public mTimer  As Long
    
    Sub timer()
      ss = DateDiff("s", Now, "2020-7-7 00:00:00")
      dd = ss \ 86400
      hh = (ss Mod 86400) \ 3600
      mm = (ss Mod 3600) \ 60
      ss = ss Mod 60
      ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text = dd & "天" & hh & "小时" & mm & "分钟" & ss & "秒"
    End Sub
    
    Sub start()
        mTimer = SetTimer(0, 0, 1000, AddressOf timer)
    End Sub
    
    Sub OnSlideShowPageChange()
        Call start
    End Sub
    
    Sub OnSlideShowTerminate()
        mTimer = KillTimer(0, mTimer)
        Application.Quit
    End Sub
    

    有时候,ppt版本可能会导致PPT播放时不能自动开始计时,网上给出了一个解决办法,就是:在当前幻灯片页加入一个小控件,可以设置为透明,或者隐藏起来。


    1.gif

    相关文章

      网友评论

          本文标题:使用VBA实现高考倒计时PPT

          本文链接:https://www.haomeiwen.com/subject/zzkvghtx.html