Table of Contents

Method SetCustomProperty

Namespace
DocWright.Word.Editing
Assembly
DocWright.Word.dll

SetCustomProperty(WordDocument, DocumentPosition, string, string)

Sets a text property, adding it when the document has none of that name (in any case).

public static DocumentEdit SetCustomProperty(this WordDocument document, DocumentPosition at, string name, string value)

Parameters

document WordDocument

The document.

at DocumentPosition

A position in the document (where the edit's caret stays).

name string

The name: 1 to 255 characters.

value string

The text.

Returns

DocumentEdit

The edit (empty when nothing changed).

Exceptions

ArgumentNullException

An argument is null.

ArgumentException

The name is empty or longer than 255 characters, or a text holds a character XML cannot carry.

InvalidOperationException

The document's custom-properties part cannot be read (it is kept, not replaced).

SetCustomProperty(WordDocument, DocumentPosition, string, int)

Sets a whole-number property (vt:i4).

public static DocumentEdit SetCustomProperty(this WordDocument document, DocumentPosition at, string name, int value)

Parameters

document WordDocument

The document.

at DocumentPosition

A position in the document (where the edit's caret stays).

name string

The name: 1 to 255 characters.

value int

The text.

Returns

DocumentEdit

The edit (empty when nothing changed).

Exceptions

ArgumentNullException

An argument is null.

ArgumentException

The name is empty or longer than 255 characters, or a text holds a character XML cannot carry.

InvalidOperationException

The document's custom-properties part cannot be read (it is kept, not replaced).

SetCustomProperty(WordDocument, DocumentPosition, string, double)

Sets a number property (vt:r8, its round-trip form).

public static DocumentEdit SetCustomProperty(this WordDocument document, DocumentPosition at, string name, double value)

Parameters

document WordDocument

The document.

at DocumentPosition

A position in the document (where the edit's caret stays).

name string

The name: 1 to 255 characters.

value double

The text.

Returns

DocumentEdit

The edit (empty when nothing changed).

Exceptions

ArgumentNullException

An argument is null.

ArgumentException

The name is empty or longer than 255 characters, or a text holds a character XML cannot carry.

InvalidOperationException

The document's custom-properties part cannot be read (it is kept, not replaced).

ArgumentException

The number is not finite, or the name is refused.

SetCustomProperty(WordDocument, DocumentPosition, string, bool)

Sets a yes-or-no property (vt:bool).

public static DocumentEdit SetCustomProperty(this WordDocument document, DocumentPosition at, string name, bool value)

Parameters

document WordDocument

The document.

at DocumentPosition

A position in the document (where the edit's caret stays).

name string

The name: 1 to 255 characters.

value bool

The text.

Returns

DocumentEdit

The edit (empty when nothing changed).

Exceptions

ArgumentNullException

An argument is null.

ArgumentException

The name is empty or longer than 255 characters, or a text holds a character XML cannot carry.

InvalidOperationException

The document's custom-properties part cannot be read (it is kept, not replaced).

SetCustomProperty(WordDocument, DocumentPosition, string, DateTime)

Sets a date property (vt:filetime), stored in UTC to the second: a local time is converted, one of unspecified kind is taken as UTC.

public static DocumentEdit SetCustomProperty(this WordDocument document, DocumentPosition at, string name, DateTime value)

Parameters

document WordDocument

The document.

at DocumentPosition

A position in the document (where the edit's caret stays).

name string

The name: 1 to 255 characters.

value DateTime

The text.

Returns

DocumentEdit

The edit (empty when nothing changed).

Exceptions

ArgumentNullException

An argument is null.

ArgumentException

The name is empty or longer than 255 characters, or a text holds a character XML cannot carry.

InvalidOperationException

The document's custom-properties part cannot be read (it is kept, not replaced).