Share via


Field Object [Publisher 2003 VBA Language Reference]

TextRange
Fields
Field
Multiple objects

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.

Using the Field Object

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. The following 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

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

Properties | Application Property | Code Property | Next Property | Parent Property | PhoneticGuide Property | Result Property | TextRange Property | Type Property

Methods | Unlink Method

Parent Objects | TextRange

Child Objects | Field | PhoneticGuide | TextRange