I have this single line of code in a Word VSTO add-in project which used to work but suddenly doesn\'t anymore:
Microsoft.Office.Interop.Word.Document doc =
From my experience : when i was closing the Active Document at that time i was refreshing Ribbon Menu according to the active document. If the closing document was the Last document i wasn't able to read any property of
Microsoft.Office.Interop.Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;
and i was facing the same issue like you.
whenever i close any document i check
if(Globals.ThisAddIn.Application.Documents.Count = 1){
LastActiveDocument = true;
}
And when i refresh the Ribbion Menu i check
if(!LastActiveDocument){
// then only read any property of Active document
}