Fields Property
Fields property as it applies to the Document, Range, and Selection objects.
Returns a read-only Fields collection that represents all the fields in the document, range, or selection.
expression.Fields
expression Required. An expression that returns one of the above objects.
Note When applied to the Document object, the Fields property returns a Fields collection that contains only the fields in the main text story.
Fields property as it applies to the MailMerge object.
Returns a read-only MailMergeFields collection that represents all the mail merge related fields in the specified document.
expression.Fields
expression Required. An expression that returns a MailMerge object.
For information about returning a single member of a collection, see Returning an Object from a Collection .
Example
As it applies to the Document, Range, and Selection objects.
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
As it applies to the Document, Range, and Selection objects.
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"
Applies to | Document Object | MailMerge Object | Range Object | Selection Object
See Also | Add Method | Code Property | Field Property | Fields Collection Object | MailMergeFields Collection Object | Result Property