Table of Contents

Method ReplaceRange

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

ReplaceRange(WordDocument, DocumentSpan, string, CharacterFormat?)

Replaces a span with text as one edit, as typing over a selection or an input-method commit does. Across paragraphs the two ends are joined, keeping the first paragraph's properties (the last's when the span starts at the first's beginning). A span that ends at the very start of a later paragraph leaves that paragraph alone, as Word does. The text takes the formatting of the first character the span covers.

public static DocumentEdit ReplaceRange(this WordDocument document, DocumentSpan span, string text, CharacterFormat? format = null)

Parameters

document WordDocument

The document that holds the span.

span DocumentSpan

The span.

text string

The text, under InsertText(WordDocument, DocumentPosition, string, CharacterFormat?)'s rules.

format CharacterFormat

The text's formatting, or null for the first covered character's.

Returns

DocumentEdit

The edit; After is just past the inserted text.

Exceptions

ArgumentNullException

document or text is null.

ArgumentException

As InsertText(WordDocument, DocumentPosition, string, CharacterFormat?) and DeleteRange(WordDocument, DocumentSpan).

InvalidOperationException

As InsertText(WordDocument, DocumentPosition, string, CharacterFormat?) and DeleteRange(WordDocument, DocumentSpan).