Neither the NewDocument nor the DocumentOpen event is fired when Microsoft Word first loads. When an instance of Word is already open and a new or existing document is opened then these events fire fine.
The suggestion I've seen is to handle the DocumentChange event (which is always fired when Word loads) instead of the other two events.
My question is how would I go about this? The DocumentChange event does not have any parameters so how would I know when the document (new or existing) was just opened?
Additionally, I already have logic in the DocumentChange event and the processing for new and existing documents is different so I can't just throw all of my code into the event.
private void ThisAddIn_Startup(object sender, System.EventArgs a)
{
this.Application.DocumentChange += new ApplicationEvents4_DocumentChangeEventHandler(Application_DocumentChange);
}
private void Application_DocumentChange()
{
// How do I handle NewDocument or DocumentOpen?
}