Being notified when a file is changed / updated.

SRMPURCHASE

Board Regular
Joined
Dec 23, 2014
Messages
212
Office Version
  1. 2016
Platform
  1. Windows
What VBA would be needed to insert into a macro to notify an email recipient that a file has been modified?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
This is only part of the solution

- FileDateTime function returns latest update time for monitored file
-Application.OnTime Now + TimeValue("01:00"), "MonitorFile" triggers macro again in 1 hour (repeatedly)
- whenever workbook containing this VBA is open, latest updated time is verified and compared
- additional procedure to SendEmail required to do the email sending

In ThisWorkbook module
Code:
Private Sub Workbook_Open()
    Call MonitorFile
End Sub
In Standard Module
Code:
Sub MonitorFile()
    Dim x As Double:    x = FileDateTime("C:\TestArea\Analysis.xlsx")
    If x > Range("A1") Then
        Call [I][B]SendEmail[/B] '[COLOR=#006400]add this procedure yourself[/COLOR][/I]
        Range("A1") = x
    End If
    Application.OnTime Now + TimeValue("01:00"), "MonitorFile"
End Sub
 
Last edited:
Upvote 0
I take it the 'add this procedure yourself note in green type is where the email address goes?
 
Upvote 0
I take it the 'add this procedure yourself noted in green type is where the email address goes?
No
- as explained, the above code is "part" of the solution
- you can test to see if it works by inserting a message box (instead of Call SendEmail ) to see if it is triggered correctly

You need to add a further procedure to generate the email itself
- perhaps you could search the forum for code to send an email
- after testing that procedure, rename it SendEmail and run it with Call SendEmail
 
Upvote 0
Perhaps someone else knows that answer about inserting the email address script?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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