DocumentProperties.Add(String, Boolean, Object, Object, Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a new custom document property.
public Microsoft.Office.Core.DocumentProperty Add (string Name, bool LinkToContent, object Type, object Value, object LinkSource);
abstract member Add : string * bool * obj * obj * obj -> Microsoft.Office.Core.DocumentProperty
Public Function Add (Name As String, LinkToContent As Boolean, Optional Type As Object, Optional Value As Object, Optional LinkSource As Object) As DocumentProperty
Parameters
- Name
- String
Required String. The name of the property.
- LinkToContent
- Boolean
Required Boolean. Specifies whether the property is linked to the contents of the container document. If this argument is True, the LinkSource
argument is required; if it's False, the value argument is required.
- Type
- Object
Optional Object. The data type of the property. Can be one of the following MsoDocProperties constants: msoPropertyTypeBoolean, msoPropertyTypeDate, msoPropertyTypeFloat, msoPropertyTypeNumber, or msoPropertyTypeString.
- Value
- Object
Optional Object. The value of the property, if it's not linked to the contents of the container document. The value is converted to match the data type specified by the type argument. If it can't be converted, an error occurs. If LinkToContent
is True, the Value
argument is ignored and the new document property is assigned a default value until the linked property values are updated by the container application (usually when the document is saved).
- LinkSource
- Object
Optional Object. Ignored if LinkToContent
is False. The source of the linked property. The container application determines what types of source linking you can use.
Returns
Remarks
If you add a custom document property to the DocumentProperties collection that’s linked to a given value in a Microsoft Office document, you must save the document to see the change to the DocumentProperty object.
You can only add a new document property to the custom DocumentProperties collection.