📜  excel 每 5 分钟运行一次宏 - VBA 代码示例

📅  最后修改于: 2022-03-11 14:51:57.057000             🧑  作者: Mango

代码示例1
Public RunWhen As Double
Public Const cRunWhat = "my_Procedure"

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 10, 0)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
     schedule:=True
End Sub

Sub StopTimer()
   On Error Resume Next
   Application.OnTime earliesttime:=RunWhen, _
       procedure:=cRunWhat, schedule:=False
End Sub

Sub my_Procedure()
    MsgBox "hello world"
    Call StartTimer
End Sub