receive an automatic Email notification when excel sheet is saved

gomaa1239

New Member
Joined
Apr 6, 2016
Messages
11
Dears,

i have an excel sheet on the shared network and a some employee can edit and save this sheet, so i need a VBA macro to send me an automatic email notification to my Email when the sheet is saved.
i think its possible possible?
it will be great if i can know who saved it and when.
im not experienced with VBA so please give me simple steps to follow to make this works.

Thanks a lot for you help and thanks in advance
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Rich (BB code):
Private Sub Workbook_AfterSave(ByVal Success As Boolean)

Dim OutApp As Object, OutMail As Object
Dim strbody As String

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

strbody = "The workbook " & ThisWorkbook.Name & " was saved at " & Format(Now, "h:mm AM/PM") & " by user " & Application.UserName

On Error Resume Next
With OutMail
    .To = "yourEmailHere@gmail.com"
    .CC = ""
    .BCC = ""
    .Subject = "Workbook " & ThisWorkbook.Name & " saved."
    .Body = strbody
    'You can add a file like this
    '.Attachments.Add ("C:\test.txt")
    .Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

End Sub

You can change the blue parts. To use this code open the VBA Editor (ALT+F11) and on the left side find your project name and double-click on the "ThisWorkbook" object. Now paste the code into the white space to the right.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,448
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top