Publishing ASP.NET Word Automation no longer will save RRS feed

  • Question

  • I've been trying to get a project live on a production server for a few users to test, and I'm having extreme difficulty.

    I have an ASP.NET page that generates a Word report. I have it working on my local host during debug. I have it working on my local IIS. But when I publish it to my Windows Server 2008 R2 production database, I get the following when trying to call the SaveAs2() method.

    Command failed

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Runtime.InteropServices.COMException: Command failed

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [COMException (0x800a1066): Command failed]
      Microsoft.Office.Interop.Word.DocumentClass.SaveAs2(Object& FileName, Object& FileFormat, Object& LockComments, Object& Password, Object& AddToRecentFiles, Object& WritePassword, Object& ReadOnlyRecommended, Object& EmbedTrueTypeFonts, Object& SaveNativePictureFormat, Object& SaveFormsData, Object& SaveAsAOCELetter, Object& Encoding, Object& InsertLineBreaks, Object& AllowSubstitutions, Object& LineEnding, Object& AddBiDiMarks, Object& CompatibilityMode) +0

    I've searched high and low, and I cannot seem to find an answer. I've come accross a bunch of people that have issues opening a Word document, but none that have the same issue I have. I am using impersonation, using both the Administrator account, as well as an account in the Administrators group to no avail. I thought it might be a permissions issue on the folder, but the Administrator account already has permissions as well as the users. Adding permissions Local Service, IUSR still didn't help.

    One thing that I have noticed is when I set the .visible = true, where Word would open on my local IIS and I could see the document building, it does not do that on the server, even when I am RDP'd in using the coresponding account. Word is open, and is building the report, because I can see it open in the Task Manager and can view the processor usage.

    I have the same version of Office installed, and from what I can tell, nothing should be different than being run from my local IIS other than Win 7 vs Win Server 2008 R2

    Any ideas? Thanks in advance!


    Tuesday, November 30, 2010 11:51 PM


All replies

  • Hello David,

    Thanks for posting. It is not recommended/supported to automation Office in any server side. For more information, please see this KB article: I quote a statement here.

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    Please refer to the part "Alternatives to server-side Automation" of the KB article. In future, if there is any help needed on OpenXML technology, I recommend you try to ask in OpenXML sites. You will probably get more support from expert there.

    - OpenXML SDK forum:

    Also here are some resources about this topic which might help you more or less.

    Command Line app runs fine by hand, but not when kicked off by a windows service:

    Exception from HRESULT: 0x800A03EC:

    If you have any concern for this post, just feel free to follow up. Have a nice day.

    Best regards,
    Bessie Zhao - MSFT
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by David.A360 Wednesday, December 1, 2010 4:33 PM
    • Unmarked as answer by David.A360 Wednesday, December 1, 2010 4:34 PM
    • Marked as answer by David.A360 Wednesday, December 1, 2010 4:34 PM
    Wednesday, December 1, 2010 6:37 AM
  • Yes, I understand all the word automation issues and the MS does not condone it. However, I still need to get this working for proof-of-concept.

    I tried adding the folder: C:\Windows\SysWOW64\config\systemprofile\Desktop and Voila! It's now working.

    Thanks for the help.

    • Proposed as answer by Saad Benbouzid Sunday, August 5, 2012 12:04 AM
    Wednesday, December 1, 2010 4:33 PM
  • Hi david.

    thanks for this solution. :)

    Tuesday, March 22, 2011 4:05 PM
  • Excellent. It worked for me. Could you explain the reason for the same.


    Also In the application pool If iam using Network Service instead of local system iam still getting error

    Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005


    Please help

    Wednesday, January 4, 2012 6:46 AM
  • Thank you so much David ! I knew I had to allow the DCOM identity as an interactive user while running under a local account, but here is what I was missing !
    Sunday, August 5, 2012 12:06 AM