How do I get notified by an email when my excel file in one drive shared folder gets updated by client
How do I get notified by an email when my excel file in one drive shared folder gets updated by client
Soumya
Provided your user uses Outlook as the email client, you can do it when the user saves the file (using the VBA workbook event AfterSave).
In the attached file, this simple code is under ThisWorkbook:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
' get the module code to send an email
Call Email_From_Excel_Basic
End Sub
(You can replace the ProjectTimeline sheet with your sheets)
The bold bit calls another macro (under Module1, based on a tutorial from Don), as follows. You may need to change the bits in bold (especially the email addresses) in VB Project Explorer:
Sub Email_From_Excel_Basic()
' TeachExcel.com
Dim emailApplication As Object
Dim emailItem As Object
Dim MyClient As String, MyRecipients As String
' name your client and your email address(es)
MyClient = "Joe Somename"
MyRecipients = "email@test.com; anotheremail@test.com"
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
' Now we build the email.
emailItem.to = MyRecipients
emailItem.Subject = "New file saved by client"
emailItem.Body = "At " & Now & ", " & MyClient & " saved this Excel file:" & vbCr & ThisWorkbook.FullName
' Send the Email
' Use this OR .Display, but not both together.
emailItem.Send
' Display the Email so the user can change it as desired before sending it.
' Use this OR .Send, but not both together.
'emailItem.Display
Set emailItem = Nothing
Set emailApplication = Nothing
' tell the user an email was sent
MsgBox "An email (advising of file save) was sent to " & vbCr & MyRecipients
End Sub
This code will also send you an email when you change that file but I guess you can live with that). When you save the file, look in your Sent folder under Outlook and you should see the email.
I've used a Message Box to tell the client (or you) that an email was sent.
You can also do this in OneDrive itself without VBA apparently, following the Microsoft guidance here :Get notified when members of your team update your shared file
Hope this fixes your problem. If so, please remember to mark this Answer as Selected.