Exception thrown when opening word docs created with older version of Aspose.Word


#1

I am trying to open a word document that was created with an Older version of Aspose.Word. When I call the Open() with a file path. An exception is raised. It is Stylesheet is missing. Any help would be verrrry appreciated Big Smile [:D] Here is the method:

Try

Dim strFiles() As String = System.IO.Directory.GetFiles(Global.g_TempDirectory, "*.doc")

If IsNothing(strFiles) = False AndAlso strFiles.Length > 0 Then

Dim iPos As Int32 = 0

Dim inStreams(strFiles.Length - 1) As System.IO.Stream

Dim pdfEditor As PdfFileEditor = New PdfFileEditor

Dim strFileName As String = String.Empty

For Each strfile As String In strFiles

'Save the document in Aspose.Pdf.Xml format into a memory stream.

'Dim stream As MemoryStream = New MemoryStream

'doc.Save(stream, SaveFormat.FormatAsposePdf)

'Seek to the beginning so it can be read by XmlDocument.

'stream.Seek(0, SeekOrigin.Begin)

Dim doc As New Document

Dim docMS As New MemoryStream

Dim wrd As New Word

'doc = New Document(strfile)

'doc.Save(docMS, SaveFormat.FormatAsposePdf)

wrd.Open(strfile).Save(strfile.Replace(".doc", ".xml"), SaveFormat.FormatAsposePdf)

'Load the document into an XmlDocument

Dim xmlDoc As XmlDocument = New XmlDocument

docMS.Seek(0, SeekOrigin.Begin)

'Load the file

xmlDoc.Load(docMS)

'Load the XML document into Aspose.Pdf

Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf

'Make sure the images that were saved by Aspose.Word into Windows temporary

'folder are automatically deleted by Aspose.Pdf when they are no longer needed.

pdf.IsImagesInXmlDeleteNeeded = True

pdf.BindXML(xmlDoc, Nothing)

strFileName = strfile.Replace("doc", "pdf")

'Now produce the PDF file.

'pdf.Save("Aspose.Word.Demos.pdf", Aspose.Pdf.SaveType.OpenInBrowser, Me.Response)

pdf.Save(strFileName)

Next

End If

Catch ex As Exception

txtError.Text = ex.Message

End Try


#2

Hi,

Thank you for your interest in Aspose.Word.

Please attach the document you mentioned.


#3

Here is an example of a word document created with an older version.


#4

The previous version was 1.6.7. I upgraded the application that generates the word document to the latest version, 3.2.0.0 and retested my code and it works! Was there a cutoff for reverse compatiabilty with Aspose.Word?


#5

Hard to answer, Aspose.Word has been producing normal Word 97 compatible documents so they should be always compatible between component versions… However, we improved styles since 1.6.7 was out so maybe that’s the cause.