none
Convert Docx to Doc programatically RRS feed

  • Question

  • I want to convert a docx file to doc on the server. I am using Microsoft.interop.Dll 11.0 to open docx file and saveas .doc format file . When I try to open docx file using interop i.e. oWord.Document.Open(docx file) i am getting COMException "Command Failed"

    Please Help

     

    Tuesday, May 17, 2011 10:35 PM

Answers

All replies

  • Hi,

    Office automation in a server is not supported but Microsoft. Said that, is Word installed on the server?

    Regards,

    Mauro


    twitter.com/mcastagnasso | castagnasso.wordpress.com | If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Wednesday, May 18, 2011 1:26 AM
  • I have Office 2003 installed on the server.
    Wednesday, May 18, 2011 1:01 PM
  • Hi,

    Well, Office 2003 doesn't support DOCX or XLSX and so on; those formats where introduced by Office 2007. You should try with Office 2007 or Office 2010.

    Regards,

    Mauro


    twitter.com/mcastagnasso | castagnasso.wordpress.com | If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Wednesday, May 18, 2011 2:56 PM
  • Well isn't it true to that Interop 11.0 is forward compatible and I can open a docx file using this Interop. I also use Interop 12.0 I am getting the same error.
    Wednesday, May 18, 2011 3:28 PM
  • Hi DotNetFreak

    Office was not designed to be used server-side, but it can be done. But in order to open a docx file in Word 2003 the Compatibility Pack must be installed. Otherwise the older version won't recognize the newer file format. Sounds to me as if that could be the cause of your problem...


    Cindy Meister, VSTO/Word MVP
    Wednesday, May 18, 2011 4:33 PM
    Moderator
  • Thanks for the support.

    I installed compatabilty pack. Now I am not getting the "Command Failed" Exception. But its hanging when interop word object tries to open docx file and then page response times out. 

    Any Idea ?

     

     

    Wednesday, May 18, 2011 11:48 PM
  • Try running it on a machine as an end-user, with the Word application Visible. My guess is that a message box is popping up, requiring user input. Possibly a request to "confirm conversions"?
    Cindy Meister, VSTO/Word MVP
    Thursday, May 19, 2011 1:31 PM
    Moderator
  • Hi ,

     I had to stall this development for a while. Now I need to get back to it.

    The hanging problem is solved only if my word document has simple text. Everything works like a charm. i.e. opening of a docx file using the interop and saving it as .doc format. 

    But my application docx files contains tables, images, formattings, bookmarks. I am having problem with these type of docx file during the opening of the file. I have tried by setting oWordAppl.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone and aslo oWordAppl.WordBasic.DisableAutoMacros(1)  but no luck. Its still hangs out when i try to open docx.

    Any other suggestions that might pop up

    Thanks

     

     

    Friday, May 27, 2011 6:12 PM
  • View my other thread where I have solved this problem.

    http://social.msdn.microsoft.com/Forums/en-US/worddev/thread/d1005a2c-9081-42eb-ab38-f54389e28a37

     Open the docx file using interop 11.0 as mentioned in above link and save it in format Word.WdSaveFormat.wdFormatDocument

    This converts a docx to doc on server side.


    Irfan Tareen
    Wednesday, June 8, 2011 8:17 PM