FormFields Property

Microsoft Word Visual Basic

FormFields Property

       

Returns a FormFields collection that represents all the form fields in the document, range, or selection. Read-only.

For information about returning a single member of a collection, see Returning an Object from a Collection.

Example

This example sets the content of the form field named "Text1" to "Name."

ActiveDocument.FormFields("Text1").Result = "Name"

This example retrieves the type of the first form field in section two.

myType = ActiveDocument.Sections(2).Range.FormFields(1).Type
Select Case myType
    Case wdFieldFormTextInput
        thetype = "TextBox"
    Case wdFieldFormDropDown
        thetype = "DropDown"
    Case wdFieldFormCheckBox
        thetype = "CheckBox"
End Select

This example displays the name of the first form field in the selection.

If Selection.FormFields.Count > 0 Then
    MsgBox Selection.FormFields(1).Name
End If