如何在VBA中执行此操作?
if (thisWorkbook.close=true) then
'do something (send email)
'and then close the workbook
end if
在关闭我的文件之前,我想发送一封电子邮件。
答案 0 :(得分:3)
使用the Workbook_BeforeClose
event。在ThisWorkbook
模块中,添加以下内容:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'do something (send email)
End Sub
您甚至可以自动插入此代码:
然后这个:
在该列表框中,您会看到all the other available Workbook events。