DocumentProperties.Add Method
Office Developer Reference |
Creates a new custom document property. You can only add a new document property to the custom DocumentProperties collection.
Syntax
expression.Add(Name, LinkToContent, Type, Value, LinkSource)
expression Required. A variable that represents a DocumentProperties object. The custom DocumentProperties object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
Name | Required | String | The name of the property. |
LinkToContent | 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 | Optional | Variant | The data type of the property. Can be one of the following MsoDocProperties constants: msoPropertyBoolean, msoPropertyDate, msoPropertyFloat, msoPropertyNumber, or msoPropertyString. |
Value | Optional | Variant | 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 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 | Optional | Variant | Ignored if LinkToContent is False. The source of the linked property. The container application determines what types of source linking you can use. |
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.
Example
This example, which is designed to run in Microsoft Word, adds three custom document properties to the DocumentProperties collection.
Visual Basic for Applications |
---|
|
See Also