Reputation: 572
How can I do this in VBA?
if (thisWorkbook.close=true) then
'do something (send email)
'and then close the workbook
end if
Before closing my file, I want to send an email.
Upvotes: 0
Views: 1641
Reputation: 38540
Use the Workbook_BeforeClose
event. In the ThisWorkbook
module, add this:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'do something (send email)
End Sub
You can even have this code inserted automatically like this:
and then this:
In that listbox you will see all the other available Workbook events.
Upvotes: 3