1.本事例時間到六點時就彈出Msgbox。ide
Sub test01() If Application.Wait("6:00:00") Then MsgBox "如今時刻六點整" '這是系統時間 End If End Sub
2.執行完這個宏10秒以後彈出Msgbox。spa
Sub test02() newHour = Hour(Now()) newMinute = Minute(Now()) newSecond = Second(Now()) + 10 waitTime = TimeSerial(newHour, newMinute, newSecond) If Application.Wait waitTime Then MsgBox "時間過去了10秒" End If End Sub
3.執行完這個宏10秒以後彈出Msgbox。orm
sub test03() If Application.Wait(Now + TimeValue("0:00:10")) Then '感受比test02簡單些 MsgBox "時間過去了10秒" End If End Sub