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:
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".
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".