vonguyenphu
New Member
- Joined
- May 26, 2019
- Messages
- 29
I know the event before workbook close but this won't work if I close the whole application (eg: via press "Alt+F4" on windows). How can I trigger event before application close?
VBA Code:
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Const sBak As String = "C:\Users\vnphu\OneDrive\Personal Workbook Backup\PERSONAL.XLSB."
Application.DisplayAlerts = False
With Workbooks("PERSONAL.XLSB")
.SaveCopyAs sBak & Format(Now(), "yyyy-mmdd-hhmm.bak")
.Save
End With
Application.DisplayAlerts = True
End Sub