Field object (Publisher)

Represents a field. The Field object is a member of the Fields collection. The Fields collection represents the fields in a selection, range, or publication.

Remarks

The pbFieldPageNumber constant is a member of the PbFieldType group of constants, which includes all the various field types.

Use TextRange.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 counts the number of fields in the active publication and displays the count in a message.

Sub CountFields() 
 Dim pagPage As Page 
 Dim shpShape As Shape 
 Dim fldField As Field 
 Dim intFields As Integer 
 Dim intCount As Integer 
 
 For Each pagPage In ActiveDocument.Pages 
 For Each shpShape In pagPage.Shapes 
 If shpShape.Type = pbTextFrame Then 
 intCount = intCount + shpShape.TextFrame.TextRange.Fields.Count 
 End If 
 Next 
 Next 
 If intCount > 0 Then 
 MsgBox "You have " & intCount & " fields in your publication." 
 Else 
 MsgBox "You have no fields in your publication." 
 End If 
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.