Having excel send an email when changes have been made [Closed]

Registration date
Wednesday May 13, 2015
Last seen
May 13, 2015

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)
'add recipients
'newmsg.Recipients.Add ("J****")
newmsg.Recipients.Add ("j****@********.org")
'add subject
newmsg.Subject = "A chart has been updated."
'add body
newmsg.Body = "Staff has updated a chart."
newmsg.Display 'display
newmsg.Send 'send message
'give conformation of sent message
MsgBox "Chart has been sent.", , "Confirmation"

End If

'save the document

End Sub

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!