|
楼主 |
发表于 2011-2-24 13:53
|
显示全部楼层
以下是每5分钟自动保存表格的代码,很有参考意义!!!
Public RunWhen As Double
Public Const cRunIntervalSeconds = 300 ' 5分钟,300秒
Public Const cRunWhat = "TheSub"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub
Sub TheSub()
ThisWorkbook.Save
StartTimer
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedure:=cRunWhat, schedule:=False
End Sub
Sub Auto_close()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedure:=cRunWhat, schedule:=False
End Sub
Sub Auto_Open()
StartTimer
End Sub |
|