我想在 Windows 之前运行一个宏shutsdown来记录时间。我写了下面的程序来在windows启动后立即运行宏。我将把它放在shortcutWindowsstartup文件夹中,这样当 Windows 启动时,它将log是当前日期的时间和日期。
但是如何在关闭 PC 之前运行宏。Start up以下相同的代码适用shut down于little change. 但是如何运行macro or code之前windows turns off
Private Sub Workbook_Open()
'
' Macro1 Macro
'
Dim Day As Date
Dim Tim As Date
Dim Row As Integer
Dim Col As Integer
Row = 1
Col = 1
Day = DateValue(Now)
Tim = TimeValue(Now)
While (Cells(Row, Col) <> "")
Row = Row + 1
Wend
Cells(Row, Col) = Day
Cells(Row, Col + 1) = Tim
ThisWorkbook.Save
'
End Sub