Fields object (Publisher)
A collection of Field objects that represent all the fields in a text range.
Remarks
The Count property for this collection in a publication returns the number of items in a specified shape or selection.
Use the TextRange.Fields property to return the Fields collection. Use Fields (index), where index is the index number, to return a single Field object. The index number represents the position of the field in the selection, range, or publication.
Example
The following example displays the field code and the result of the first field in each text box in the active publication.
Sub ShowFieldCodes()
Dim pagPage As Page
Dim shpShape As Shape
For Each pagPage In ActiveDocument.Pages
For Each shpShape In pagPage.Shapes
If shpShape.Type = pbTextFrame Then
With shpShape.TextFrame.TextRange
If .Fields.Count > 0 Then
MsgBox "Code = " & .Fields(1).Code & vbLf _
& "Result = " & .Fields(1).Result & vbLf
End If
End With
End If
Next
Next
End Sub
Methods
Properties
See also
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.