Copying/moving sections hints and issues


If you want to move a section into a blank Word document, please note that although the document is “blank” it will always contain at least one section with one paragraph mark in MS Word.

Therefore you will end up with two sections. If that’s not what you want, just remove the original “single paragraph” section from the destination document either before or after you added the new section.

Document dstDoc = TestUtil.Open(“blank.doc”);
Document srcDoc = TestUtil.Open(“simpletable.doc”);

//Remove the always present “blank” section.

//Move a section from source to the destination document.
Section section = srcDoc.Sections[0];


When you move or copy a section from one document to another there could be an issue related to document styles used in the source document and not available in the destination document.

Aspose.Word 1.3 throws an exception index out of range.
Aspose.Word 1.4 just reverts to normal paragraph or normal character style if it cannot find a style in the destination document.

If you want to workaround exception in 1.3 or avoid formatting being lost in 1.4 then make sure both source and destination documents have the same styles.

We might later need to improve handling of styles even further when copying sections between documents.