Method DeleteRange
DeleteRange(WordDocument, DocumentSpan)
Deletes the content of a span. Within a paragraph the text and whole inlines it covers go. Across paragraphs the paragraphs between go, the first keeps what precedes the span (and goes too when the span starts at its beginning), the last keeps what follows it, and the two are not joined, as Word's Delete does. A span that is only a paragraph mark joins the two paragraphs, as the Delete key at a paragraph's end does.
public static DocumentEdit DeleteRange(this WordDocument document, DocumentSpan span)
Parameters
documentWordDocumentThe document that holds the span.
spanDocumentSpanThe span.
Returns
- DocumentEdit
The edit; After is where the span was.
Remarks
A bookmark, hyperlink, field or inline content control the span covers whole goes; one the span covers only part of stays, with its covered text gone and its markers where the span was.
Exceptions
- ArgumentNullException
documentis null.- ArgumentException
The span is not in
document, or an end falls inside a surrogate pair.- InvalidOperationException
The span crosses a container boundary (a table cell; a section break is removed, as Word does) or covers a block other than a paragraph.