We are trying to send an email when a excel file is saved we are currently using 2010 cant seem to get it work. We have never created a maco, and it doesn't seem to see the below exists as a macro. Below is the code that we are trying attempting to use:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim answer As String
answer = MsgBox("This is where you put the text to prompt the user if he wants to save or not" vbYesNo, "here is the title of that box")
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.Recipients.Add ("JIMMY John")
newmsg.Subject = "test Save"
newmsg.Body = "This is a test from excel"
newmsg.Send 'send message
'give conformation of sent message
MsgBox "insert confirmation box test here", , "title of confirmation box"
'save the document