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

When trying to open a document (.doc or .docx), the document instance is NULL.

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

      

And why is wordApplication.Documents.Count zero?

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

+3


source to share


1 answer


This helped me a few years ago.

Built in

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

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



2nd: you have to change the id of the word component in windows\System32\comexp.msc

to be interactive user, not run user.

3rd:
0. Set the DCOM setting for "Microsoft Office Word 97 - 2003 Document"
  (Open Properties> Identity Tab> Select Interactive User Secutiry Tab> Lanuch and Acctivation Permissions> AddNetwork Serivce

  • Save settings
  • Open your virtual directory in IIS
  • Select virtual directory
  • Select "Authentication".
  • Change Anonymous Authentication Dialog Box
  • open> click on set button> admin (any admin user is good)
+5


source







All Articles