Search code examples
c#asp.netoffice-interop

Word ActiveX control - Can I intercept SaveAs?


In our intranet application we are generating and displaying word documents. Users can edit them and send modified to server. After we generate documents we save the path to documents to later send them. But we have a problem when user saves document as (which they often do because they need it later), edit it and hit Send button on page. Because we remember paths to generated files we send those instead of edited ones.

Is there any way to intercept SaveAs command to update our stored filepaths?

We are using Microsoft.Office.Interop.Word.ApplicationClass.


Solution

  • You can use the ApplicationEvents4.DocumentBeforeSave event

    Here is an detailed example of how to handle word events in C#