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.
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 (I've verified this by adding a msgbox popup within Workbook_AfterSave and Workbook_BeforeSave and it definitely doesn't popup when using the send as attachment within Excel).
So, I'm digging around with Google trying to find out what other options I might have to fix my loophole.
Background: My code in Workbook_AfterSave and Workbook_BeforeSave hides tabs, very hidden, where the user cannot see them at all. The user can hack the workbook, and see the hidden tabs, by using this email as attachment "feature".
Simplification of problem: Create a new workbook with no VBA Code in it an save as an .xlsm file. Add the following code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "Before Save"
End Sub
Select file->share->email->send as attachment. Note you get no message box; however, if you made any changes they were most certainly saved =).