Document.CustomDocumentProperties property (Word)

Returns a DocumentProperties collection that represents all the custom document properties for the specified document.

Syntax

expression.CustomDocumentProperties

expression Required. A variable that represents a Document object.

Remarks

Use the BuiltInDocumentProperties property to return the collection of built-in document properties.

Properties of type msoPropertyTypeString (MsoDocProperties) cannot exceed 255 characters in length.

For information about returning a single member of a collection, see Returning an object from a collection.

Example

This example inserts a list of custom document properties at the end of the active document.

Set myRange = ActiveDocument.Content 
myRange.Collapse Direction:=wdCollapseEnd 
For Each prop In ActiveDocument.CustomDocumentProperties 
 With myRange 
 .InsertParagraphAfter 
 .InsertAfter prop.Name & "= " 
 .InsertAfter prop.Value 
 End With 
Next

This example adds a custom document property to Sales.doc.

thename = InputBox("Please type your name", "Name") 
Documents("Sales.doc").CustomDocumentProperties.Add _ 
 Name:="YourName", LinkToContent:=False, Value:=thename, _ 
 Type:=msoPropertyTypeString

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.