Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Office.Interop.Word.Application.Documents.Open("C:\\doc.doc") not open

When i trying to open the document (.doc or .docx) instance of document is NULL.

Application wordApplication = new Application();
wordApplication.Visible = false;
Document wordDocument =  wordApplication.Documents.Open("C:\\doc.doc");

And why is wordApplication.Documents.Count equal of zero?

(Windows Server 2008 R2 x64, MS Office 2010 x64)

like image 657
Kavaliou Avatar asked May 24 '26 05:05

Kavaliou


1 Answers

This helped me several years ago.

Inlined

There are several suggested answers, I tried the second one and it solved my problem. But I'm inlining all of them here/.

1-st approach: try to create a new "Desktop" directory inside of "C:\Windows\SysWOW64\config\systemprofile\"

2-nd: you must change the identity of word component in windows\System32\comexp.msc to be interactive user instead of launching user.

3-rd:
0. Set the DCOM Config Setting for "Microsoft Office Word 97 - 2003 Document"
(Open the properties > Identity Tab > Select "The interative User" Secutiry Tab > Lanuch and Acctivation Permissions > Add Network Serivce

  1. Save the settings
  2. Open your Virtual directory in IIS
  3. Select the Virtual directory
  4. Select "Authentication".
  5. Edit anonymous authentication
  6. Dialog box will get opened > click on set > admin user (any admin user is good)
like image 60
alex.b Avatar answered May 26 '26 17:05

alex.b



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!