DocumentProperties.Add Method
Creates a new custom document property.
Namespace: Microsoft.Office.Core
Assembly: office (in office.dll)
Syntax
'Declaration
Function Add ( _
Name As String, _
LinkToContent As Boolean, _
Type As Object, _
Value As Object, _
LinkSource As Object _
) As DocumentProperty
'Usage
Dim instance As DocumentProperties
Dim Name As String
Dim LinkToContent As Boolean
Dim Type As Object
Dim Value As Object
Dim LinkSource As Object
Dim returnValue As DocumentProperty
returnValue = instance.Add(Name, LinkToContent, _
Type, Value, LinkSource)
DocumentProperty Add(
string Name,
bool LinkToContent,
Object Type,
Object Value,
Object LinkSource
)
Parameters
Name
Type: System.StringRequired String. The name of the property.
LinkToContent
Type: System.BooleanRequired 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
Type: System.ObjectOptional Object. The data type of the property. Can be one of the following MsoDocProperties constants: msoPropertyTypeBoolean, msoPropertyTypeDate, msoPropertyTypeFloat, msoPropertyTypeNumber, or msoPropertyTypeString.
Value
Type: System.ObjectOptional 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
Type: System.ObjectOptional Object. Ignored if LinkToContent is False. The source of the linked property. The container application determines what types of source linking you can use.
Return Value
Type: Microsoft.Office.Core.DocumentProperty
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.