Word.Application.Documents.Add(filePath) returns null in in IIS7 in Windows Server 2008 R2 64 bit RRS feed

  • Question

  • I am trying to manipulate Word 2007 documents in an application hosted in IIS7 in Windows Server 2008 R2 64bit machine. When I run the Word.Application.Add() command, it returns null.

    Below is the code snippet:

    Word.Application wApp = null;
                Word.Document wDoc = null;
                object missing = Type.Missing;
                Type typWord = null;
                object objTrue = true;
                object wordInstance = null;
                object sourcePath = @"C:\Windows\Temp\abcd.docx";
                typWord = System.Type.GetTypeFromProgID("Word.Application");
                wordInstance = System.Activator.CreateInstance(typWord);
                wApp = wordInstance as Word.Application;
                wDoc = wApp.Documents.Add(ref sourcePath, ref objTrue, ref missing, ref missing);

    I have tried the same code in another server and it worked. It creates the instance of Word.Application successfully but cannot execute the Add() command properly. I tried with the wApp.Documents.Open() method with no luck.

    I have enabled the [Local Access]/[Remote Access] for [Network Services] and then [Everyone] in ComExp.exe>Com Security>Access Permission and enabled [Local/Remote] [Activation/Launch] for the same users. But NO LUCK.

    And there is no entry for Microsoft word or any other office applications in [Component Services\Computers\My Computer\DCOM Config] so that I could enable permission.

    Is there anyone who can help me on this urgent issue?

    Thanks in advance....

    Wednesday, July 11, 2012 10:15 AM


All replies