In a VSTO addin for Word 16 (32) on a Windows 10, I keep track of each document for Ribbon purposes.
I am using the VSTO Designer's Application object. In the designer it looks like this;
Friend WithEvents Application As Microsoft.Office.Interop.Word.Application
Then in ThisAddinn I have the standard code for a WithEvents object.
Private Sub Application_NewDocument(Doc As Microsoft.Office.Interop.Word.Document) Handles Application.NewDocument
End Sub
In ThisAddin I also handle Application.DocumentOpen
After the first instance of Word is open if a user right clicks on the Word icon in the task bar and chooses Word then a new Word document is created, however the above 2 events do not fire.
I also wanted to point out that opening a document from the Word interface or clicking on a word.docx file and opening it all work. It is only when you open a new instance of work by right clicking on the word icon in the task bar.
What event do I need?
I do see that Application.WindowActivate fires. Do I need to use this?