Method SetCustomProperty
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
documentWordDocumentThe document.
atDocumentPositionA position in the document (where the edit's caret stays).
namestringThe name: 1 to 255 characters.
valuestringThe 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
documentWordDocumentThe document.
atDocumentPositionA position in the document (where the edit's caret stays).
namestringThe name: 1 to 255 characters.
valueintThe 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
documentWordDocumentThe document.
atDocumentPositionA position in the document (where the edit's caret stays).
namestringThe name: 1 to 255 characters.
valuedoubleThe 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
documentWordDocumentThe document.
atDocumentPositionA position in the document (where the edit's caret stays).
namestringThe name: 1 to 255 characters.
valueboolThe 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
documentWordDocumentThe document.
atDocumentPositionA position in the document (where the edit's caret stays).
namestringThe name: 1 to 255 characters.
valueDateTimeThe 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).