Add Method (DocumentProperties Collection)

Applies To

DocumentProperties Collection.

Description

Creates a new custom document property. Returns a DocumentProperty object.

To use this method, you should establish a reference to the Microsoft Office 95 Object Library by using the References command (Tools menu).

Syntax

object.Add(name, linkToContent, type, value, linkSource)

object

Required. The custom DocumentProperties collection object.

name

Required. The name of the property.

linkToContent

Required. Specifies whether the property is linked to the content of the container document. If True, the linkSource argument is required. If False, the value argument is required.

type

Required. The data type of the property (can be one of offPropertyTypeBoolean, offPropertyTypeDate, offPropertyTypeFloat, offPropertyTypeString, or offPropertyTypeNumber).

value

Optional. The value of the property if it's not linked to the content of the container document. The value is converted to match the data type specified by the type argument, if possible; otherwise, an error occurs. If linkToContent is True, this argument is ignored and the new document property has a default value until linked property values are updated by the container application (usually when the document is saved).

linkSource

Optional. Ignored if linkToContent is False. The source of the linked property. The container application determines what types of source linking are allowed.

Remarks

This method cannot be used with the collection of built-in document properties.

Example

This example adds a new custom document property. You must pass the custom DocumentProperties collection to the procedure.


Sub AddCustomProperty(dp As DocumentProperties)
    dp.Add name:="Complete", linkToContent:=False, _
        type:=offPropertyTypeBoolean, value:=False
End Sub

This example adds a static custom property named "Complete."


With ActiveWorkbook.CustomDocumentProperties
    .Add name := "Complete", linkToContent := False, _
        type := offPropertyTypeBoolean, value := False
End With

This example adds a property linked to the name "Grand_Total."


With ActiveWorkbook.CustomDocumentProperties
    .Add name := "Total Sales", linkToContent := True, _
        linkSource := "Grand_Total"
End With