So, I finished processing the uploaded document in ThisAddIn_Startup. If the Document Path is an empty string, we know that the document is new and has never been saved on the local computer. In addition, I know that it is saved (including in the temp directory), and I treat it as an existing document.
private void ThisAddIn_Startup(object sender, System.EventArgs a)
{
try
{
Word.Document doc = this.Application.ActiveDocument;
if (String.IsNullOrWhiteSpace(doc.Path))
{
ProcessNewDocument(doc);
}
else
{
ProcessDocumentOpen(doc);
}
}
catch (COMException e)
{
log.Debug("No document loaded with word.");
}
((MSWord.ApplicationEvents4_Event)this.Application).NewDocument +=
new MSWord.ApplicationEvents4_NewDocumentEventHandler(Application_NewDocument);
this.Application.DocumentOpen +=
new MSWord.ApplicationEvents4_DocumentOpenEventHandler(Application_DocumentOpen);
}
Deni :
DocumentOpen ThisAddIn.Desiger.cs Initialize() , NewDocument , Word, . DocumentOpen NewDocument ThisAddIn_Startup, DocumentOpen , Word.