We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Crash in MS Word after using NodeImporter with KeepSourceFormatting

In a certain document, we're having a problem where it crashes MS Word in a specific set of circumstances:

1) Use Aspose.Words NodeImporter to copy the sections of this document, using the routine below, and save it.

2) Open MS Word 2003, go into VBA editor, and run "Documents.Open yourFilepath" (either in the immediate window, or in macro code) to open the file.

3) Select the first or third paragraph (including the paragraph marker), and copy it.

4) Now either close the document, or attempt to paste into another Word document. Either will cause MS Word to crash.

We don't see the problem if we copy the contents of the document to a new document before working with it in Aspose. We have not been able to reproduce the problem without having used Aspose to copy the document. We don't get the problem in Office 2000. We don't get the problem if we double click the file to open it instead of using Documents.Open. We don't have the problem if we don't copy anything. We don't have the problem if we only select a part of the first or third paragraph (without the paragraph marker), or if we select only the second or fourth paragraph.

I have attached a cleaned up version of the original document, before using Aspose. Since we can only attach one thing at a time, I will reply to this post and include the "after" document that has the problem in it.

Private Function FixStyles(ByVal fileBytes As Byte()) As Byte()

'Create a document object from a stream created from the byte array

Dim blobStream As New System.IO.MemoryStream(fileBytes)

Try

AsposeCommon.LoadLicence(True)

Dim uploadDoc As New Aspose.Words.Document(blobStream)

Dim newDoc As Aspose.Words.Document = CType(uploadDoc.Clone(False), Aspose.Words.Document)

Dim NodeImporter As New Aspose.Words.NodeImporter(uploadDoc, newDoc, Aspose.Words.ImportFormatMode.KeepSourceFormatting)

For Each srcSection As Aspose.Words.Section In uploadDoc

Dim dstSection As Aspose.Words.Node = NodeImporter.ImportNode(srcSection, True)

newDoc.AppendChild(dstSection)

Next

blobStream = New System.IO.MemoryStream

newDoc.Save(blobStream, Aspose.Words.SaveFormat.Doc)

fileBytes = blobStream.GetBuffer

Finally

blobStream.Dispose()

End Try

Return fileBytes

End Function

Here is the document after copying it using Aspose.

Thanks for providing all the necessary info. I have reproduced the problem and logged it to our defect base as issue #3078. We will try to fix it as soon as possible.

Do you have an estimate of when this fix will be available? Thanks.

The issue is not fixed yet. I will post a notification here as soon as the fix will be available. And sorry, I cannot provide any ETA at the moment.

Best regards,

Any update on this issue? Thanks

Sorry no updates yet.

Sorry it took so long, I’m trying to fix it now.

I cannot reproduce on my MS Word 2003. Also tried on 2007. Followed your steps exactly. Maybe this was fixed by other changes. Try latest Aspose.Words 4.3.1 when it will be released later today.

I'm closing the issue in the meantime. If you still have the same problem when using Aspose.Words 4.3.1, please let us know.

I tried this in version 4.4, and it appears to be fixed.

Hi

I have tried to reproduce your problem using the latest version of Aspose.Words (v 4.4.1.0) and it seems that all works fine on my side.

The latest version of Aspose.Words is available for download from here.

Best regards.