Method FormatSections
FormatSections(WordDocument, DocumentSpan, Action<SectionFormat>)
Changes the section formatting (page size, orientation, margins, columns …) of every section a span touches, as Word's page setup does for the sections a selection covers.
public static DocumentEdit FormatSections(this WordDocument document, DocumentSpan span, Action<SectionFormat> change)
Parameters
documentWordDocumentThe document that holds the span.
spanDocumentSpanThe span; an empty span is the section it is in.
changeAction<SectionFormat>Changes a copy of each section's format, which the edit swaps in; undo puts back the instance that was there.
Returns
- DocumentEdit
The edit. Its ChangedParagraphKeys are every paragraph of the changed sections, table cells included.
Exceptions
- ArgumentNullException
documentorchangeis null.- ArgumentException
The span is not in
document.- InvalidOperationException
An end is in a shape's text box, or outside the body (a header, footer or note belongs to no one section).