2

I have been using the Microsoft Office Interop Word for quite some time without any issues, but now all of a sudden it has stopped working. It now gives me the exception message

Word could not fire the event

I'm running the latest update of Windows 10 Pro - 1809, I have office 2016 installed also with the latest updates. And I'm running Visual studio 2017

I use the code below to test the issue:

using System;
using Word = Microsoft.Office.Interop.Word;

namespace WordTesting
{
    class Program
    {
        static void Main(string[] args)
        {
            Word.Application application = new Word.Application();
            application.Visible = false;
            Word.Document document = null;
            try
            {
                document = application.Documents.Open(@"C:\Users\caspe\Desktop\TEST.docx", Visible: false);
            }
            catch (Exception e)
            {
                application.Quit();
                Console.WriteLine("Exception: {0}", e.Message);
            }
            Console.ReadKey();
        }
    }
}

Here are my References: References

The Code above throws a:

Exception thrown: 'System.Runtime.InteropServices.COMException' in WordTesting.exe

And the Console.Writeline is:

Exception: Word could not fire the event

Full exception:

System.Runtime.InteropServices.COMException: 'Word could not fire the event.'

UPDATE

I have just tested my build on another windows 10 machine with build 180 and there it works like a charm

I hope someone can find a solution to the issue, because I haven't been able to find one.

Bjqn
  • 146
  • 2
  • 19
  • can this be reproduced with any document, or is it specifically occurring with your TEST.docx only? does it make a difference when there is a different path? does it make a difference when you run it in the debugger vs. unattended/release build – Cee McSharpface Jan 29 '19 at 14:19
  • Any document. Even `application.Documents.add();` to create a empty document will throw the exception. – Bjqn Jan 29 '19 at 14:22
  • No, release or debug doesn't change anything. – Bjqn Jan 29 '19 at 14:27
  • Over the last few months there have been various issues with "the interop" due to some of Microsoft's updates. Try rolling back the Windows and Office updates until you're back to a state where the code is able to execute. (Or test on a machine without updates.) – Cindy Meister Jan 29 '19 at 16:27

1 Answers1

0

Okay this is a strange solution. But I found it in here last post on this page and here

So basically it's a region thing. I had my region to ENG[DAN], because Denmark. But when I changed everything to ENG[US] it worked again.

I have some other parts of my implementation that still doesn't work, but for now this is good enough.

Bjqn
  • 146
  • 2
  • 19