C#C
C#2y ago
M B V R K

Marshal.GetActiveObject("Word.Application") fall in exception

I'm working on a .NET Framework console application,
I have added the Microsoft.Office.Interop.Word as a reference
I have wrote a line of code that get an object from the opening instance of Microsoft Word as following :
Application wordApp = Marshal.GetActiveObject("Word.Application") as Application;

The issue:
When I run the application, it always throw an exception for that line as shown in the attached video

Please does anyone has any idea or solution for this issue ?

Massive thanks in advance <3
Was this page helpful?