none
Microsoft Word.Interop 2010 has issue with Open method() with Works document (.wps) RRS feed

  • Question

  • I'm making a simple test WinForms C# application to open documents in Word. When I try opening .wps files (with my application) on a computer with Office 2010 installed, I get the following error:

    System.Runtime.InteropServices.COMException (0x800A169F): There is not enough memory or disk space to convert this document.
       at Microsoft.Office.Interop.Word.Documents.Open(Object& FileName, Object& ConfirmConversions, Object& ReadOnly, Object& AddToRecentFiles, Object& PasswordDocument, Object& PasswordTemplate, Object& Revert, Object& WritePasswordDocument, Object& WritePasswordTemplate, Object& Format, Object& Encoding, Object& Visible, Object& OpenAndRepair, Object& DocumentDirection, Object& NoEncodingDialog, Object& XMLTransform)

    However, I can open any other file type like Word documents fine. I can also manually open the .wps file through Office 2010 fine as well. And this issue does not exists on computers with Office 2007 or earlier installed. Here is a snippet of the code:

                Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
                wordApp.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
                wordApp.Visible = true;
                using (OpenFileDialog dlg = new OpenFileDialog())
                {
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        object infileObj = dlg.FileName;
                        object trueObj = true;
                        object falseObj = false;
                        object missing = Type.Missing;
                        object docPasswordObj = "test";

                        Microsoft.Office.Interop.Word.Document wordDoc = wordApp.Documents.Open(ref infileObj, ref falseObj, ref trueObj, ref falseObj, ref docPasswordObj, ref missing, ref trueObj, ref missing,
                            ref missing,ref missing, ref missing, ref trueObj, ref trueObj, ref missing, ref missing, ref missing);
                        wordDoc.Activate();
                    }
                }

    Any ideas? Thanks!

    Tuesday, April 24, 2012 4:05 PM

All replies

  • Hi Stevo

    I'm going to move this to the Word for Developers forum as you're not using the VSTO technology. You'll find more people there who specialize in Word.

    FWIW, I've heard there've been some discussions on the Answers (end-users) site about problems with opening Works documents in Word 2010 since a recent Windows security update. So your issue may be related, even though you're able to open the document successfully manually.

    Something else you could try, however, would be to specify the file converter (Format parameter) to use when opening a Works file. As I don't see a value for Works in the WdOpenFormat enum, I've copied this from a Word object model Help file:
    "The file converter to be used to open the document. Can be one of the following WdOpenFormat constants. To specify an external file format, apply the OpenFormat property to a FileConverter object to determine the value to use with this argument."

    Before you go to all that work you might try recording a macro when opening the file manually. That might tell you 1) whether Word is using the Format parameter and 2) what it's using. If it does specify it, the value will be a number that, as best I can recall, is an ordinal that will be specific to that installation. IOW you won't be able to use that in code that runs on other machines. But it should give you a leg-up on determining the FileConverter Word is using.


    Cindy Meister, VSTO/Word MVP

    Wednesday, April 25, 2012 8:05 AM
    Moderator
  • Thank you for your response.

    I ran an Macro and got this as the output:

    Documents.Open FileName:="20120000135657.wps", ConfirmConversions:=False, _
            ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
            PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
            WritePasswordTemplate:="", Format:=25

    Looking up the fileconverter that matched that format, it is "MSWorksWin9 Wks9Pxy.cnv".

    I tried replicating that in C#, hardcoding the 25 and as well the FileConverter.OpenFormat property and both still give the same error of "System.Runtime.InteropServices.COMException (0x800A169F): There is not enough memory or disk space to convert this document.".

    I understand VBA and C# interop with Word is different, but any idea what else could be causing the issue?

    I cannot seem to find any article with unable to open Works document in Word 2010 from a security update, but will dig around some more.

    Wednesday, April 25, 2012 7:58 PM
  • Hi Stevo

    Browsing around yesterday, I picked this up:

    An updated converter is available for download here: http://www.microsoft.com/download/en/details.aspx?id=12


    Cindy Meister, VSTO/Word MVP

    Thursday, April 26, 2012 8:08 AM
    Moderator
  • Hi Cindy,

    Thank you for your response.

    I'm narrowing down on the problem sort of.

    For the DCOM Permission, "Microsoft Word 97-2003 Document" I have set the identity to a specific user (actually the exact same user I'm logged in) and that causes the Memory error. If I set it to be launching user or interactive user, it opens the WPS totally fine.

    The setting of the identity to a specific user is necessary since were using Word Interop as a service. (I understand there are complications with that). It starting to sound like a permission issue not being set properly for possibly another component. Do you know Word 2010 introduced a new component of some sort?

    Thursday, April 26, 2012 5:40 PM
  • Hi Stevo

    With DCOM you're outside my area of expertise, I'm afraid.. I have no idea about what could be different in 2010 in this respect.

    <<The setting of the identity to a specific user is necessary since were using Word Interop as a service. (I understand there are complications with that). >>

    Yes, as you're experiencing.

    That's why the new file formats and the new Automation Services (http://msdn.microsoft.com/en-us/library/ee558830.aspx) were introduced. Possibly, the latter could help you?


    Cindy Meister, VSTO/Word MVP

    Friday, April 27, 2012 8:13 AM
    Moderator