Can't access Interop properties from C#

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 !
Only importing those COM and try to access some properties, only that sadly
It works normally for me, but I have sometimes problems with Office Interop and they are usually fixed by a "Quick Repair" (in Control Panel, Right click on Office, Update; it mainly repairs registry)
How did you import those COM?
@Cédric SANCHEZ ,based on my test, I find that I can access the properties of Interop.
Please try the following code example to check if it works for you.
@Cédric SANCHEZ , is any update?
Sign in to comment
1 answer
Sort by: Most helpful
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.
Sign in to comment