Private Sub Workbook_BeforeClose(Cancel As Boolean) Open Application.Path & "\test.txt" _ For Append As #1 Print #1, "Stopped " & Now Close #1End Sub