Fully or partially copying one document into another is a very popular task. Here is a "pattern" to implement this.
Before any node from another document can be inserted, it must be imported using Document.ImportNode. The Document.ImportNode method makes a copy of the original node and updates all internal document-specific attributes such as lists and styles to make them valid in the destination document.
Example SectionsImportSection
Shows how to copy sections between documents.
[C#]
Document srcDoc = new Document(MyDir + "Document.doc");
Document dstDoc = new Document();
Section sourceSection = srcDoc.Sections[0];
Section newSection = (Section)dstDoc.ImportNode(sourceSection, true);
dstDoc.Sections.Add(newSection);
[Visual Basic]
Dim srcDoc As Document = New Document(MyDir & "Document.doc")
Dim dstDoc As Document = New Document()
Dim sourceSection As Section = srcDoc.Sections(0)
Dim newSection As Section = CType(dstDoc.ImportNode(sourceSection, True), Section)
dstDoc.Sections.Add(newSection)
[Java]
Document srcDoc = new Document(getMyDir() + "Document.doc");
Document dstDoc = new Document();
Section sourceSection = srcDoc.getSections().get(0);
Section newSection = (Section)dstDoc.importNode(sourceSection, true);
dstDoc.getSections().add(newSection);
Sometimes it is necessary to avoid section breaks in the destination document. In this case, you can use Section.AppendContent instead of Sections.Add.