'Word 2013 and up - (Asynchronous) Document load finished event?

I have a WinForms-app that loads pretty big Word documents (up to 1000 pages) via Interop with a multitude of letters, each containing some text pages and some with page-filling pictures (2 or 3 pictures in a row). The app is meant to correct the document for duplex printing, adding empty pages where needed.

The software correctly identifies certain pages in the individual letters with a specific symbol as a Word.Range. It then tries to identify the page number of these symbols with:

range.Document.Repaginate(); //force Word to recount the pages
range.get_Information(Word.WdInformation.wdActiveEndPageNumber);

If the symbol is on an uneven page, it adds a line break.

My problem is the asynchronous loading of newer Word versions (after Word 2010) where it seems that pictures only get loaded when in view. So the aforementioned page filling pictures are not correctly counted as pages because Word interprets them as containing 2 or 3 empty spaces. Outputting the page number from the above code at the symbols location shows, that the pictures are missing during the runtime of the code. This means that when I check the documents afterwards the symbol/outputted page number are for example on page 162 but the outputted string says 160 - the page where the first pic is.

My question is: how can I force my code to wait until the whole document and especially the pictures are completely loaded?

Addendum: I have near to no influence on the original creation of theses Word documents, they are produced by an external software.

Thanks for your help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source