Add Method

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. For more information, click "Specifics" at the top of this topic.

Remarks

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


Add Method 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


Count Property

Returns the number of document properties in the DocumentProperties collection. Read-only.

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


Count Property Example

This example displays the number of document properties in a collection. You must pass a DocumentProperties collection to the procedure.

Sub CountDocumentProperties(dp As DocumentProperties)

    MsgBox "There are " & dp.Count & " properties in the collection."

End Sub


Delete Method

Deletes a custom document property (you cannot delete a built-in document property).

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


Delete Method Example

This example deletes a custom document property. You must pass a DocumentProperty object to the procedure.

Sub DeleteCustomDocumentProperty(dp As DocumentProperty)

    dp.Delete

End Sub


DocumentProperties Collection Object

Represents a collection of document properties. Each document property is represented by a DocumentProperty object.

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

Use the BuiltinDocumentProperties property to return the collection of built-in document properties, and use the CustomDocumentProperties property to return the collection of custom document properties. For more information about returning document properties from a container application, click "Specifics" at the top of this topic.

Use the Add method to create a new custom document property and add it to the collection (you cannot create a built-in document property).


DocumentProperty Object

Represents a single document property. The DocumentProperty object is a member of the DocumentProperties collection.

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

Use the BuiltinDocumentProperties property to return the collection of built-in document properties, and use the CustomDocumentProperties property to return the collection of custom document properties. Use the Item method to return a single member of the collection. For more information about returning individual document properties from a container application, click "Specifics" at the top of this topic.


Item Method

Accessor. Returns a single DocumentProperty object from the collection of document properties.

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

Remarks

Because the Item method is the default method for the DocumentProperties collection object, the following statements are identical.

CustomDocumentProperties.Item(1)

CustomDocumentProperties(1)

You can refer to document properties either by index value or by name. The following list shows the available built-in document property names:

Title, Subject, Author, Keywords, Comments, Template, Last Author, Revision Number, Application Name, Last Print Date, Creation Date, Last Save Time, Total Editing Time, Number of Pages, Number of Words, Number of Characters, Security, Category, Format, Manager, Company, Number of Bytes, Number of Lines, Number of Paragraphs, Number of Slides, Number of Notes, Number of Hidden Slides, Number of Multimedia Clips

Container applications aren't required to define values for every built-in document property. If the application doesn't define a value for one of the built-in document properties, reading the Value property for that document property causes an error.


Item Method Example

This example displays the names of the document properties in a collection. You must pass a DocumentProperties collection to the procedure.

Sub DisplayPropertyNames(dp As DocumentProperties)

    Dim i As Integer

    For i = 1 To dp.Count

        MsgBox dp.Item(i).Name

    Next

End Sub


LinkToContent Property

True if the value of a custom document property is linked to the content of the container document; False if the value is static. Read-write.

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

Remarks

This property applies only to custom document properties. For built-in document properties, this property is always False.

Use the LinkSource property to set the source for the linked property. Setting the LinkSource property sets the LinkToContent property to True.

For more information about setting this property in a container application, click "Specifics" at the top of this topic.


LinkToContent Property Example

This example displays the linked status of a custom document property. You must pass a DocumentProperty object to the procedure.

Sub DisplayLinkStatus(dp As DocumentProperty)

    Dim stat As String, tf As String

    If dp.LinkToContent Then

        tf = ""

    Else

        tf = "not "

    End If

    stat = "This property is " & tf & "linked"

    If dp.LinkToContent Then

        stat = stat + Chr(13) & "The link source is " & dp.LinkSource

    End If

    MsgBox stat

End Sub


LinkSource Property

Returns or sets the source of a linked custom document property. Read-write.

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

Remarks

The source of a link is defined by the container application. For more information about link sources, click "Specifics" at the top of this topic.

This property cannot be used with built-in document properties.

Setting the LinkSource property sets the LinkToContent property to True.


LinkSource Property Example

This example displays the linked status of a custom document property. You must pass a DocumentProperty object to the procedure.

Sub DisplayLinkStatus(dp As DocumentProperty)

    Dim stat As String, tf As String

    If dp.LinkToContent Then

        tf = ""

    Else

        tf = "not "

    End If

    stat = "This property is " & tf & "linked"

    If dp.LinkToContent Then

        stat = stat + Chr(13) & "The link source is " & dp.LinkSource

    End If

    MsgBox stat

End Sub


Name Property

Returns or sets the name of the document property. Read-only for built-in document properties; read-write for custom document properties.

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

For a list of valid built-in document property names, see the Item method.


Name Property Example

This example displays the name, type, and value of a document property. You must pass a DocumentProperty object to the procedure.

Sub DisplayPropertyInfo(dp As DocumentProperty)

    MsgBox "value = " & dp.Value & Chr(13) & _

        "type = " & dp.Type & Chr(13) & _

        "name = " & dp.Name

End Sub


Parent Property

Accessor. Returns the parent object for the specified object. Read-only.

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


Parent Property Example

This example displays the name of the parent for a document property. You must pass a DocumentProperty object to the procedure.

Sub DisplayParent(dp as DocumentProperty)

MsgBox dp.Parent.Name

End Sub


Type Property

Returns or sets the document property type (can be one of offPropertyTypeBoolean, offPropertyTypeDate, offPropertyTypeFloat, offPropertyTypeNumber, or offPropertyTypeString). Read-only for built-in document properties; read-write for custom document properties.

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


Type Property Example

This example displays the name, type, and value of a document property. You must pass a DocumentProperty object to the procedure.

Sub DisplayPropertyInfo(dp As DocumentProperty)

    MsgBox "value = " & dp.Value & Chr(13) & _

        "type = " & dp.Type & Chr(13) & _

        "name = " & dp.Name

End Sub


Value Property

Returns or sets the document property value. Read-write.

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

Remarks

If the application doesn't define a value for one of the built-in document properties, reading the Value property for that document property causes an error.


Value Property Example

This example displays the name, type, and value of a document property. You must pass a DocumentProperty object to the procedure.

Sub DisplayPropertyInfo(dp As DocumentProperty)

    MsgBox "value = " & dp.Value & Chr(13) & _

        "type = " & dp.Type & Chr(13) & _

        "name = " & dp.Name

End Sub


Using the Microsoft Office 95 Object Library

When you use custom or built-in document properties from Visual Basic, you should establish a link to the Microsoft Office 95 Object Library by using the References command (Tools menu). Select the check box next to the object library name in the References dialog box.

This object library contains definitions for the Visual Basic objects, properties, methods, and constants used to manipulate document properties. You can use document properties in Visual Basic without referencing the Microsoft Office 95 Object Library, but you cannot use named constants or syntax checking, declare object variables of type DocumentProperty or DocumentProperties, or use the Object Browser or context-sensitive Help.