Class TextInput (Word VBA)

The class TextInput represents a single text form field.


To use a TextInput class variable it first needs to be instantiated, for example

Dim tit as TextInput
Set tit = ActiveDocument.FormFields(1).TextInput

TextInput class variables can be set using the FormField.TextInput procedure.


Deletes the text from the specified text form field.

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True 
If ActiveDocument.FormFields(1).Type = wdFieldFormTextInput Then 
End If


Returns or sets the text that represents the default text box contents.

ActiveDocument.FormFields(1).TextInput.Default =


Sets options for the specified text form field.

Syntax : expression.EditType (Type, Default, Format, Enabled)

With ActiveDocument.FormFields.Add _ 
 (Range:=ActiveDocument.Range(0, 0), _ 
 .Name = "Today" 
 .TextInput.EditType Type:=wdCurrentDateText, _ 
 Format:="M/d/yy", Enabled:=False 
End With


The following argument is required

Type (WdTextFormFieldType) - The text box type.

Possible Values are

wdCalculationText Calculation text field.
wdCurrentDateText Current date text field.
wdCurrentTimeText Current time text field.
wdDateText Date text field.
wdNumberText Number text field.
wdRegularText Regular text field.

The following arguments are optional

Default (String) - The default text that appears in the text box.

Format (String) - The formatting string used to format the text, number, or date (for example, "0.00," "Title Case," or "M/d/yy"). For more examples of formats, see the list of formats for the specified text form field type in the Text Form Field Options dialog box.

Enabled (Boolean) - True to enable the form field for text entry.


Returns the text formatting for the specified text box.

If ActiveDocument.FormFields(1).Type = wdFieldFormTextInput Then 
 MsgBox ActiveDocument.FormFields(1).TextInput.Format 
 MsgBox "First field is not a text form field" 
End If


Returns an object that represents the parent object of the specified TextInput object.

Dim objParent As Object
Set objParent = ActiveDocument.FormFields(1).TextInput.Parent


Returns the type of text form field.

Possible Values are wdCalculationText - Calculation text field, wdCurrentDateText - Current date text field, wdCurrentTimeText - Current time text field, wdDateText - Date text field, wdNumberText - Number text field, wdRegularText - Regular text field.
Dim wtfType As WdTextFormFieldType
wtfType = ActiveDocument.FormFields(1).TextInput.Type


True if the specified form field object is a valid check box form field. Read-only Boolean.

If ActiveDocument.FormFields(1).TextInput.Valid = True Then 
 ActiveDocument.FormFields(1).Result = "Hello" 
End If


Returns or sets the width, in points, of the specified text input field.

ActiveDocument.FormFields(1).TextInput.Width =