I am trying to set up a macro in Keyboard Maestro that runs automatically when a specific Excel file is updated either when new data is added / when it’s saved. My goal is to monitor a spreadsheet I use for tracking tasks & trigger a few automated actions (like sending a notification, copying values / launching a script) whenever that file changes.
I know KM can monitor folders and UI elements but I am not sure how reliable it would be to watch a single Excel file for changes especially since Microsoft Excel autosaves in the background.
While reviewing what is Microsoft Excel and how it handles background saves and temp files on macOS; I realized there may be hidden limitations. Any help or creative ideas would be appreciated!
As with most requests, it may help us to know what you are doing this for.
But it any case, here's what I would do to solve your problem.
I would create a macro that triggers once per minute (or it may suffice to trigger when Excel closes, depending on whether you always close Excel after editing the file) which performs an MD5 hash of the file you want to monitor, and if the hash changes, perform the tasks that you want, including notifying you. It would look something like this. Does this get you started, or am I misunderstanding the problem? (Most macros that monitor things should start with a Semaphore Lock action, but I didn't add that here. I'll tell you about it later if you like this approach.)
How is that file being changed? By you, manually? By automations? By other people?
But just knowing that a file has changed may not help you much anyway -- you probably also need to know what has changed. Which won't be easy...
Is Excel even the right tool for the job? There are plenty of task trackers out there and, since they're usually based on records in a database rather than cells in a spreadsheet, many of them have built-in notification/automation on change.
For no better reason than it's the first that springs to mind -- how about Trello?
You can use the Execute Shell Script to run the macOS/Unix stat command to retrieve a file's modification date, comparing that to the last stored value to detect a change.
stat -f "%Sm" bw.htm, for example, returned Jul 11 09:00:27 2025 on my system just now.
If you accept Excel file with macros I suggest to use synergy of both environments.
Use VBA event AfterSave to notify rest of the world about saving the file by call a small Apple Script handler.
The steps done by me:
Save workbook in format with macros (file extension xlsm)
Go to code editor (Tools-->Macro-->Visual Basic Editor
Paste code for Workbook_AfterSave (see below)
Go to ~//Library/Application Scripts/com.microsoft.Excel/ and save file TestExcelAppleScript.applescript (see below)
Save workbook again
Each time when yo write the workbook you will see notification
Code for macro:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Dim myScriptResult As String
myScriptResult = AppleScriptTask("TestExcelAppleScript.applescript", "AppleScriptSaveHandler", "Hello from Excel")
End Sub
Code for Apple Script:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use *scripting additions*
on AppleScriptSaveHandler(paramString)
display notification paramString ¬
with title "Notification from Excel"
end AppleScriptSaveHandler