Handle DocumentBeforeSafe Event

Add-in Express™ Support Service
That's what is more important than anything else

Handle DocumentBeforeSafe Event



I have code which should be run when saving a document.
Therefore I added the adxWordAppEvents component and have a function linked to the DocumentBeforeSave event. Which works well when explicitely is saved.

However when a modified word document is closed, MS Word shows a dialog questioning the user whether the document should be saved.
When the user then picks 'no' the safe beforesafeevent is fired regardless. But since the document is not saved, I need my code to be skipped.
The parameters Cancel or SaveAsUI do not change and are always false. But I think these are only for controlling purposes, right?

Is there a way to see what the user choose / if the document is actually being saved?

Best regards,
Posted 23 Aug, 2022 08:13:32 Top
Andrei Smolin

Add-in Express team

Posts: 18661
Joined: 2006-05-11
Hello Michiel,

I suggest that you check if the Document.Saved is true or false in the Commandbars.Update event occurring after the DocumentBeforeSave event. In Add-in Express, the event Commandbars.Update event is mapped to the CommandbarsUpdate event of the ADXWordAppEvents component.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 25 Aug, 2022 04:06:08 Top