Class FormFields (Word VBA)
A collection of FormField objects that represent all the form fields in a selection, range, or document. To use a FormFields class variable it first needs to be instantiated, for example
Dim ffs as FormFields
Set ffs = ActiveDocument.FormFields
For Each
Here is an example of processing the FormFields items in a collection.
Dim ffd As FormField
For Each ffd In ActiveDocument.FormFields
Next ffd
Add
Returns a FormField object that represents a new form field added at a range.
Selection.Collapse Direction:=wdCollapseEnd
Set ffield = ActiveDocument.FormFields _
.Add(Range:=Selection.Range, Type:=wdFieldFormCheckBox)
With ffield
.Name = "Check_Box_1"
.CheckBox.Value = True
End With
Arguments
The following arguments are required:
Range (Range) - The range where you want to add the form field. If the range isn't collapsed, the form field replaces the range.
Type (WdFieldType) - The type of form field to add.
Here you can find possible values for
Count
Returns a Long that represents the number of fields in the collection.
Dim lngCount As Long
lngCount = ActiveDocument.FormFields.Count
Item
Returns an individual FormField object in a collection.
Item (Index)
Index: The individual object to be returned. Can be a Long indicating the ordinal position or a String representing the name of the individual object.
Dim ffd As FormField
Set ffd = ActiveDocument.FormFields(Index:=1)
Shaded
True if shading is applied to form fields.
Shading makes form fields easier to locate in a document and doesn't affect the printed output.
Documents("Employment Form.doc").FormFields.Shaded = False