C# Convert DOC to DOCX without Interop

Error: system.argumentoutofrangeexception non-negative number required
aspose.words error c# convert doc to docx without interop.jpg (276.3 KB)

Code:

static string ConvertDocToDocxWithoutInterop(string docPath)
{
    string docxPath = string.Format("{0}x", docPath);
    Document doc = new Document(docPath);
    doc.Save(docxPath, SaveFormat.Docx);
    return docxPath;
}

Note:
There are some embedded .pdf OLE objects in the DOC file.

@gbw,

Have you tried to run the following C# convert DOC to DOCX without Interop code by using the latest (21.8) version of Aspose.Words for .NET on your end?

using Aspose.Words;

namespace Aspose.Examples
{
    class Program
    {
        static void Main(string[] args)
        {
            ApplyLicense();

            // Convert Word DOC with Embedded PDF OLE Objects to DOCX File
            ConvertDocToDocxWithoutInterop("word.doc", "output.docx");
        }

        public static void ConvertDocToDocxWithoutInterop(string docPath, string docxPath)
        {
            Document doc = new Document(docPath);
            doc.Save(docxPath, SaveFormat.Docx);
        }

        public static void ApplyLicense()
        {
            Aspose.Words.License wordsLic = new Aspose.Words.License();
            wordsLic.SetLicense("path.lic");
        }
    }
}

In case the problem still remains, then please ZIP and upload your input Word DOC document that you are getting this system.argumentoutofrangeexception with here for testing on our end.

Thanks for your reply
I updated the Asopse.Word.dll to v21.8, but the issue still exist. And the doc file contains sensitive content, I’m so sorry I couldn’t send it to you.
Could you please provide some possible reasons?

@gbw,

Unfortunately, it is difficult to say what the problem is without the document. We need your specific DOC file containing the embedded PDF OLE objects to be able to reproduce the following exception on our end.

system.argumentoutofrangeexception non-negative number required

Please note that it is safe to attach Word DOC files in the forum. If you attach your file here, then only you and Aspose staff members can download it. You can also remove any sensitive information by replacing it with dummy data instead (make sure that the problem is still reproducible with the simplified/ modified DOC file).