I am currently developing a Vsto Word Addin in C#.
I am looking for an event that is thrown every time a new document is changed and the document is fully loaded and displayed to the user.
I need this event to make adjustments to the header and footer of the document and to call up the document information using this line (Globals.ThisAddIn.Application.CommandBars.ExecuteMso(‘DocumentInformationShowHide’);).
I have already tested the ‘word.Application.DocumentChange’ event, which is fired too early, before the document is loaded and displayed to the user.
public async void Application_DocumentChange()
{
_logger.Info("Application_DocumentChange event triggered.");
ManipulateHeaderAndFooter();
Globals.ThisAddIn.Application.CommandBars.ExecuteMso("DocumentInformationShowHide");
}
This blocks Word completely for me when using DocumentChanged Event:
- open Word without an open document .
- create a new document via the Word UI using a template or even a blank document.
- the DocumentChanged event is fired and the document information is attempted to be displayed.
- Word blocks and falls into a kind of deadlock as shown in the screenshot.
Thats why i need a Event that triggers later (after document is loaded and already displayed to the user) or another workaround for it.