How to Detect Word Save and Print Events Using JavaScript API
Question details
The user needs to detect when a document is saved or printed using the Word JavaScript API, but encounters an invalid-parameters error when attempting to use SettingsChanged.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Developing a Word add-in that triggers custom actions when a user saves or prints a document.
- Observed behavior
- Calling Office.context.document.addHandlerAsync with SettingsChanged returns an invalid-parameters error instead of successfully hooking into save or print events.
Ensure you are referencing the latest version of the Office JavaScript API (Office.js) and check the official Microsoft 365 developer documentation for newly supported event handlers.
Understand Word JavaScript API Limitations and Seek Alternatives
The Word JavaScript API currently lacks direct event handlers for save (Ctrl+S) and print (Ctrl+P) actions. You must use alternative development approaches to accomplish your goal.
Currently, the Word JavaScript API does not natively support document-level events like 'DocumentSaved' or 'DocumentPrinted'. Attempting to use addHandlerAsync with unsupported event types like SettingsChanged for this purpose will result in an invalid-parameters error.
To achieve save or print detection, developers need to rely on alternative add-in architectures or consult Microsoft's developer community for web-based workarounds.
Check the official Office JavaScript API requirement sets to confirm if any new event handlers have been introduced for your specific Word version.
Post your specific use case on the Microsoft Q&A forum under the 'Office Development' tag to get advice on the most current workarounds from expert developers.
If direct save and print detection is strictly required and you are targeting Windows desktop users, consider building a VSTO (Visual Studio Tools for Office) or COM add-in, which provides full access to DocumentBeforeSave and DocumentBeforePrint events.

Looking for a Developer-Friendly Office Alternative?
If Microsoft Office API limitations are slowing down your workflow, consider trying WPS Office. It offers a lightweight, highly compatible suite with powerful macro support for advanced document automation.
- 1. Download WPS Office: Visit the official WPS website and download the free version for your operating system.
- 2. Install the application: Run the installer and follow the on-screen instructions to complete the setup.
- 3. Explore automation features: Open WPS Writer and navigate to the Developer tab to explore macro recording and scripting capabilities.

Frequently Asked Questions
Why do I get an invalid-parameters error with SettingsChanged?
The SettingsChanged event is designed to fire when custom settings in the document are updated, not when the document is saved or printed. Passing it incorrectly or in an unsupported context will trigger an invalid-parameters error.
Are there any workarounds for detecting when a document is saved?
In the web-based JavaScript API, direct save detection is limited. However, you can create a custom save button within your add-in's task pane that performs your required actions before explicitly calling the document save method.
Can VSTO add-ins detect print and save events?
Yes. Unlike the web-based JavaScript API, VSTO and COM add-ins for desktop versions of Office have full access to application-level events, including DocumentBeforeSave and DocumentBeforePrint.




