Excel Send As Attachment Menu Option

LotusWaide123

New Member
Joined
Nov 16, 2017
Messages
3
I have some code that I have put in Workbook_AfterSave and Workbook_BeforeSave. It works great and does exactly what I want; however, during testing, I found an odd situation where Excel doesn't call these two functions when saving a document (maybe Excel is disabling events on its own here).

If I have a document open and select file->share->email->send as attachment, then Excel saves my document and puts it into an email message without ever calling Workbook_AfterSave and Workbook_BeforeSave.


To test with the most basic conditions...

1) Create a new workbook with no VBA Code in it an save as an .xlsm file. Add the following code:

Code:
   Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

         MsgBox "Before Save"

   End Sub

2) Select file->share->email->send as attachment. Note you get no message box; however, if you made any changes they were most certainly saved in the email attachment - open it and take a look =).

I'm wondering if there is a way to get around this behavior - I'm currently reading your website to see if I can find an application event I can trap when someone clicks on "send as attachment".
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,224,813
Messages
6,181,115
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top