我想在 Windows 之前运行一个宏shutsdown
来记录时间。我写了下面的程序来在windows
启动后立即运行宏。我将把它放在shortcut
Windowsstartup
文件夹中,这样当 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