Implementing a FORMTEXT Class

Visual Basic User's Guide > Using Microsoft Word Fields

The FormText field is used in MS Word to create fillable documents. In many applications, such documents are automated, so that these fields must be readable to be completed automatically. A TX Text Control field acts like a container for all settings (switches) of these fields.

This sample implements a class for the FormText fields. Everytime, a field of type FORMTEXT should be edited, a new FormText object is created:

[Visual Basic]
Dim newMergeField As New MergeField
Set newMergeField.TextControl = TXTextControl1
newMergeField.FieldID = oID

A reference to the TXTextControl.FieldCurrent is stored in the FormText instance. Similar to the first sample, this identifier is used to get or set the parameters that are mapped to the properties of the new implemented FormText object.

A dialog box is implemented to change the properties of the specific form text field. The dialog represents the properties of the implemented FormText field:

After clicking OK, the specified values in the dialog box are set in the implemented FormText object which writes the parameters of the referenced field of TX Text Control.