通过循环,在满足指定日期、时间的情况,进行相应的操作。
Option Explicit
Sub printout_temp()
Dim i As Long
Dim temp As String
'日期判断
' Do Until Date = "2018-12-7"
' Debug.Print Date
' Loop
' Debug.Print "Done"
' Debug.Print Date
'时间判断
' Debug.Print Time
' temp = Time
' Do Until Time = "16:32:40"
' Debug.Print Time
' i = i + 1
' Loop
' Debug.Print temp
' Debug.Print "Done"
' Debug.Print i
'日期和时间的综合判断
Do Until Now = "2018-12-7 16:37:00"
Debug.Print Now
Loop
Debug.Print "Done"
Debug.Print Now
' 调用word对象: https://docs.microsoft.com/zh-cn/office/vba/api/word.document
' Documents(1).Select
' Documents(1).PrintPreview
End Sub