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 !

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,236 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,482 questions
{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