If you want to copy and insert just the main text of a section excluding the section separator and section properties, use Section.PrependContent or Section.AppendContent passing a Section object for the content being copied. No new section is created, headers and footers are not copied. The former method inserts a copy of the content at the beginning of the section, while the latter inserts a copy of the content at the end of the section.
Example SectionsAppendSectionContent
Shows how to append content of an existing section. The number of sections in the document remains the same.
[C#]
Document doc = new Document(MyDir + "Section.AppendContent.doc");
// This is the section that we will append and prepend to.
Section section = doc.Sections[2];
// This copies content of the 1st section and inserts it at the beginning of the specified section.
Section sectionToPrepend = doc.Sections[0];
section.PrependContent(sectionToPrepend);
// This copies content of the 2nd section and inserts it at the end of the specified section.
Section sectionToAppend = doc.Sections[1];
section.AppendContent(sectionToAppend);
[Visual Basic]
Dim doc As Document = New Document(MyDir & "Section.AppendContent.doc")
' This is the section that we will append and prepend to.
Dim section As Section = doc.Sections(2)
' This copies content of the 1st section and inserts it at the beginning of the specified section.
Dim sectionToPrepend As Section = doc.Sections(0)
section.PrependContent(sectionToPrepend)
' This copies content of the 2nd section and inserts it at the end of the specified section.
Dim sectionToAppend As Section = doc.Sections(1)
section.AppendContent(sectionToAppend)
[Java]
Document doc = new Document(getMyDir() + "Section.AppendContent.doc");
// This is the section that we will append and prepend to.
Section section = doc.getSections().get(2);
// This copies content of the 1st section and inserts it at the beginning of the specified section.
Section sectionToPrepend = doc.getSections().get(0);
section.prependContent(sectionToPrepend);
// This copies content of the 2nd section and inserts it at the end of the specified section.
Section sectionToAppend = doc.getSections().get(1);
section.appendContent(sectionToAppend);