Fields Property

Applies To

Document object, MailMerge object, Range object, Selection object.

Description

Document, Range, or Selection object: Returns a Fields collection that represents all the fields in the document, range, or selection. Read-only.

Note When applied to the Document object, the Fields property returns a Fields collection that contains only the fields in the main text story.

MailMerge object: Returns a MailMergeFields collection that represents all the mail merge related fields in the specified document. Read-only.

See Also

Add method (Fields collection), Add method (MailMergeFields collection), Code property, Field property, Fields collection object, MailMergeFields collection object, Result property.

Example

This example updates all the fields in the active document.

ActiveDocument.Fields.Update
This example removes all the fields from the main text story and the footer in the active document.

For Each aField in ActiveDocument.Fields
    aField.Delete
Next aField
Set myRange = ActiveDocument.Sections(1).Footers _
    (wdHeaderFooterPrimary).Range
For Each aField In myRange.Fields
    aField.Delete
Next aField
This example adds a DATE field at the insertion point.

With Selection
    .Collapse Direction:=wdCollapseStart
    .Fields.Add Range:=Selection.Range, Type:=wdFieldDate
End With
This example adds a mail merge field named "Title" at the insertion point.

Selection.Collapse Direction:=wdCollapseStart
ActiveDocument.MailMerge.Fields.Add Range:= Selection.Range, _
    Name:= "Title"