TextInput Object
FormField TextInput |
Represents a single text form field.
Using the TextInput Object
Use FormFields(index), where index is either the bookmark name associated with the text form field or the index number, to return a FormField object. Use the TextInput property with the FormField object to return a TextInput object. The following example deletes the contents of the text form field named "Text1" in the active document.
ActiveDocument.FormFields("Text1").TextInput.Clear
The index number represents the position of the form field in the FormFields collection. The following example checks the type of the first form field in the active document. If the form field is a text form field, the example sets "Mission Critical" as the value of the field.
If ActiveDocument.FormFields(1).Type = wdFieldFormTextInput Then
ActiveDocument.FormFields(1).Result = "Mission Critical"
End If
The following example determines whether the ffield
variable represents a valid text form field in the active document before it sets the default text.
Set ffield = ActiveDocument.FormFields(1).TextInput
If ffield.Valid = True Then
ffield.Default = "Type your name here"
Else
MsgBox "First field is not a text box"
End If
Use the Add method with the FormFields object to add a text form field. The following example adds a text form field at the beginning of the active document and then sets the name of the form field to "FirstName."
Set ffield = ActiveDocument.FormFields.Add( _
Range:=ActiveDocument.Range(Start:=0, End:=0), _
Type:=wdFieldFormTextInput)
ffield.Name = "FirstName"
Properties | Application Property | Creator Property | Default Property | Format Property | Parent Property | Type Property | Valid Property | Width Property
Methods | Clear Method | EditType Method
Parent Objects | FormField Object
Child Objects
See Also | CheckBox Object | DropDown Object