Table of Contents

Method InsertText

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

InsertText(WordDocument, DocumentPosition, string, CharacterFormat?)

Inserts text at a position. A \t becomes a tab, a \v a line break, and \r\n, \n or \r a paragraph split, as plain-text paste does.

public static DocumentEdit InsertText(this WordDocument document, DocumentPosition at, string text, CharacterFormat? format = null)

Parameters

document WordDocument

The document that holds the position.

at DocumentPosition

Where to insert.

text string

The text.

format CharacterFormat

The text's formatting, or null for the formatting Word gives typed text there.

Returns

DocumentEdit

The edit; After is just past the inserted text.

Exceptions

ArgumentNullException

document or text is null.

ArgumentException

The position is not in document, falls inside a surrogate pair, or the text holds a control character other than tab, vertical tab and line endings, a non-character, or an unpaired surrogate.

ArgumentOutOfRangeException

The position's offset is outside its paragraph's content.

InvalidOperationException

The text holds a line ending and the position is inside an inline content control, or the position is inside content a reader synthesized.