Can't access Interop properties from C#

Cédric SANCHEZ 1 Reputation point
2022-01-25T10:33:01.097+00:00

Hello everybody,

I'm encountering a problem with a C# .NET 4.8 project, while trying to use Office interop. If I use Interop.Microsoft.Office.Interop.Excel, Interop.Microsoft.Office.Interop.Outlook or Interop.Microsoft.Office.Interop.Word, I can not access any properties. The only way to get any informations from the COM object is to use some methods.

Example :

Microsoft.Office.Interop.Word.Application _wordApplication;
var documents = _wordApplication.Documents;

This is not working anymore

Microsoft.Office.Interop.Word.Application _wordApplication;
var documents = _wordApplication.get_Documents();

This is working right now but encounters other problems.

Any advice to why those interops suddenly don't expose their properties ?

Thank you !

Microsoft 365 and Office Development Other
Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. Artemiy Moroz 271 Reputation points
    2022-01-25T12:08:52.56+00:00

    Hi there!
    I suggest you drop using Office interop in favor of OpenXML SDK
    The latter needs a little bit of learning and supports only Office 2007+ documents, but there are lots of code samples over the Internet. Also, OpenXML SDK does not require Office installed on the machine, which excludes the influence of Office's own bugs on your program. I recommend investing some time in studying OpenXML SDK, this will surely pay off to you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.