DocumentProperties.Add method

Creates a new custom document property.

Namespace:  Microsoft.Office.Core
Assembly:  office (in office.dll)

[LCIDConversionAttribute()]
DocumentProperty Add(
	string Name,
	bool LinkToContent,
	Object Type,
	Object Value,
	Object LinkSource
)

Parameters

Name
Type: System.String

Required String. The name of the property.

LinkToContent
Type: System.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
Type: System.Object

Optional Object. The data type of the property. Can be one of the following MsoDocProperties constants: msoPropertyTypeBoolean, msoPropertyTypeDate, msoPropertyTypeFloat, msoPropertyTypeNumber, or msoPropertyTypeString.

Value
Type: System.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
Type: System.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.

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.

Show: