A few words of thanks would be greatly appreciated.

Generate Email Notifications for Excel Sheet Updates

When working on a shared network, it is very common for multiple employees to access and change common files throughout the day. This article will explain how to implement a macro in Microsoft Excel that will send an automated email each time a change is made to a common document.

Excel Macro to Signal Document Changes

You may program this macro to send out emails to specific team members to alert them of changes to a network file.

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)
'add recipients
'newmsg.Recipients.Add ("Name Here")
newmsg.Recipients.Add ("sampleemailaddresshere@email.com")
'add subject
newmsg.Subject = "Subject line of auto email here"
'add body
newmsg.Body = "body of auto email here"
newmsg.Display 'display
newmsg.Send 'send message
'give conformation of sent message
MsgBox "insert confirmation box test here",, "title of confirmation box"

End If

'save the document

End Sub

Photo: Unsplash

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Generate Email Notifications for Excel Sheet Updates », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).
1 Comment

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!