I recently saw that a code was given to have an auto email sent out once the workbook was save. I tried the code but nothing happened for me. Below is the code, what am I doing wrong? Using excel 2010
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim answer As String
answer = MsgBox("Do you want to save your changes?", vbYesNo, "Save")
If answer = vbNo Then Cancel = True
If answer = vbYes Then
'open outlook type stuff
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)
newmsg.Subject = "A chart has been updated."
newmsg.Body = "Staff has updated a chart."
newmsg.Send 'send message
'give conformation of sent message
MsgBox "Chart has been sent.", , "Confirmation"
'save the document
Having excel send an email when changes have been made