Exception from Word.ApplicationClass.Activedocument all of a sudden

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 = Globals.ThisAddIn.Application.ActiveDocument;

Before it just returned the Document object as it was supposed to, and I could read from and manipulate it without issue. But now it throws a System.Runtime.InteropServices.COMException exception. "Word has encountered a problem." Very helpful. The exception contains an HRESULT of 0x800A13E9, which hasn't helped me so far either. Out of memory or something? Idk.

The new behavior seems to have started around New Year's Eve (not sure since I wasn't using the add-in for the past couple of weeks), and it started while the add-in was installed, i.e. nothing in the code was changed, recompiled or reinstalled to make it happen. I've since rebuilt the project, thinking maybe a certificate had expired or something, but the error still occurs.

It's maybe worth noting that I can still access other properties of the Application instance. For instance, this line does not throw an exception:

int numDocuments = Globals.ThisAddIn.Application.Documents.Count;

But then when I iterate over the Documents collection with foreach, it just skips over the loop as if the count was zero.

The only thing I can think of is that an update to Office (365) has broken something related to VSTO. But where do I even begin debugging this?

Okay, so I tried creating a new Word VSTO add-in, changing none of the default project properties, but adding a single ribbon with a single button and the following method:

private void button1_Click(object sender, RibbonControlEventArgs e)
        var x = Globals.ThisAddIn.Application.ActiveDocument;
    catch  (Exception ex)

It throws exactly the same exception on getting the ActiveDocument property. I did however notice that there are two more exceptions thrown when loading the add-in, and they're also thrown when loading the original add-in (that used to work fine):

Exception thrown: 'System.Deployment.Application.DeploymentException' in System.Deployment.dll
Exception thrown: 'System.Security.Cryptography.CryptographicException' in Microsoft.VisualStudio.Tools.Applications.Hosting.dll

They don't prevent the add-in from loading and running, but maybe they're related to the problem anyway? I don't know if they were also thrown last year before the problem appeared.

I do however have a couple of Excel add-ins that still run fine with the same version of VSTO, Visual Studio and Office, and they don't throw the above two exceptions when loading. So the issue seems to be specific to Word.

And now I tried rolling back to Office 365 version 1810, the October release, which definitely worked before, so I think it's probably not a problem introduced by an Office update. It's something else. Probably.

Not that it really helps me much, but at least I've ruled that out. Probably.

The problem seems to be triggered by the Windows 10 October 2018 Update (or November). The affected customers had special Windows regional settings: Example: "English (Switzerland)". Solution: Change the Windows regional settings format to "English (UK)" or "English (US)"

The VBA Editor also no longer worked correctly for the affected customers (without installed add-ins). The error "Word has encountered a problem" (Visual Basic Error 5097) occurred directly during opening. The same error that occurs in C# for Application.ActiveDocument

jacob ComObject with java 6 not working anymore since Windows , Exception from Word.ApplicationClass.Activedocument all of a sudden where the problem only started with 1809. Can you try to Change the  Exception from Word.ApplicationClass.Activedocument all of a sudden where the problem only started with 1809. Can you try to Change the Windows regional settings format to "English (UK)" or "English (US)" When it is not a difference in the language, then the Enterprise editions might get some group policy affecting this.

Well, rolling back to the previous version of Windows 10 (1803 in my case, apparently) fixed the issue, and I can't reproduce it at the moment, so I'll mark this as solved for now.

While I still have no clue what exactly the deal was, I did at least learn in my research that clicking the "Check for updates" button in Windows 10 instantly makes you a beta tester for Microsoft. As in, they deliberately put you on the unstable update train, without any sort of notice, let alone a warning that you're about to install updates that they don't consider ready for release yet.

Anyway, I hope they got some good telemetry from my many, many hours of trying everything I could think of, so that maybe the issue is fixed by the time the update is forced on me. If not, I guess I'll be back to ask the same question again. At least I'll know where to start looking for the cause.

Newest 'comexception' Questions, Exception from Word.ApplicationClass.Activedocument all of a sudden. I have this single line of code in a Word VSTO add-in project which used to work but  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Exception from Word.ApplicationClass.Activedocument all of a sudden

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

// then only read any property of Active document

Recently Active 'comexception' Questions, Exception from Word.ApplicationClass.Activedocument all of a sudden · c# ms-​word office365 vsto comexception · Mar 26 '19 at 7:41 Andrew Faerber. 7. 1  For Minecraft on the PC, a GameFAQs message board topic titled "Minecraft keeps crashing randomly all of a sudden.".

Microsoft has fixed the issue Microsoft has released an Office update to fix this issue. With Office Version 1902 (Build 11328.20158) the issue is fixed on my side.

Error: "Unable to cast COM object of type 'Microsoft.Office.Interop , Word.ApplicationClass' to interface type 'Microsoft.Office.Interop. supported (​Exception from HRESULT: 0x80004002 (E_NOINTERFACE))." The region of 50,000 on a quiet part of the Oregon Coast became a target of anger after passing a directive that all residents wear masks indoors and outdoors — with a few exceptions, including

This command is not available because no document is open., COMException: This command is not available because no document is open. Source Error: Document oDoc = app.ActiveDocument;. Brought  Im so lost! It was working perfectly and then all of a sudden I keep getting notifications on my wall of this over and over and im not sure what to do! Please help!! Thanks in advance! Nisas_Last_Exception.txt

Retrieve current document path - Office, Sudden problem with VSTO Hello Dino, I had similar problems after I installed Orcas CTP on my machine. Tried everything Is there a method that would work for all programs listed above Something like Office.Interop.Word.​ApplicationClass": propertyName = "ActiveDocument";. break; catch (Exception​) { //Outlook has 

  • So, Office 365... And version of Windows, just for the sake of thoroughness? Recent Windows 10 updates (last few months = recent) have had some negative effects on the Interop, although I, personally, haven't experienced them...
  • Windows 10 Pro version 1809, which I believe is the most recent. I tried the six most recent versions of Office 365 already, via the cumbersome rollback method, and also completely removing it and all settings and reinstalling, but the error remains. So maybe it is related to a Windows update. I guess I'll try rolling that back next, once I have Office back up and running with all the settings. Grr.
  • Tip: If you suspect Office try a REPAIR, not remove and re-install. REPAIR updates/corrects Registry settings, re-installing does not.
  • The other thing to check is whether the document(s) open in the Word application are "sand-boxed" - in a protected window. This isn't something that should just be happening now as it was introduced more than five years ago, but I thought I'd better mention it...
  • Thanks for the suggestions, but I tried repairing already. And although I think the sandboxing may have something to do with it, there is definitely a document present in the Documents collection, and it's definitely not protected view or read-only mode or some such. Also I believe the exception thrown would be different if that were the cause.
  • I get this, and the add-in is careful to check that there is at least one document present, especially because of protected view and such. But if I add int y = Globals.ThisAddIn.Application.Documents.Count; to the minimal example above, there's clearly a document there (y=1 when running the add-in with a new, empty document, for example)