Script to send excel sheet at close of excel

Closed
gregoryps Posts 8 Registration date Tuesday 8 June 2010 Status Member Last seen 11 June 2010 - 9 Jun 2010 à 11:10
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 9 Jun 2010 à 12:36
Hello,

Is there a way to write a script to copy a sheet and email it when someone closed excel? I am trying to get a sheet called "Daily Closures" to email when they close excel.

Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
9 Jun 2010 à 11:37
Define you email routine under "ThisWorkbook"

This is the routine that you need to target for emailing

Private Sub Workbook_BeforeClose(Cancel As Boolean)

End Sub
gregoryps Posts 8 Registration date Tuesday 8 June 2010 Status Member Last seen 11 June 2010
9 Jun 2010 à 11:55
Thank you. I have written a script to email data from a sheet, but not an entire sheet as a excel file. I will try to write the script.
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
9 Jun 2010 à 12:36
Perhaps most easy way might be if you export that sheet as a new workbook and then use send book via email

Here is a good example

https://www.ozgrid.com/VBA/send-email.htm