Deleting Section Breaks


#1

I've been using Bookmarks and Continuous Section breaks to mark sections of the document that I'd like to show and remove. After the document is generated, many of the continuous section breaks are left in the document. Is there a way to remove all of the continous section breaks in the document in one shot? I don't want to remove the page breaks, just the continuous section breaks.

Thanks!


#2

Please try the following code:

ArrayList sections = new ArrayList();

foreach (Section section in doc.Sections)

{

sections.Add(section);

}

foreach (Section section in sections)

{

if (section.PageSetup.SectionStart == SectionStart.Continuous)

{

Section prevSection = (Section)section.PreviousSibling;

section.Remove();

prevSection.AppendContent(section);

}

}

Best regards,