Upravit

Sdílet prostřednictvím


FormFields.Add method (Word)

Returns a FormField object that represents a new form field added at a range.

Syntax

expression.Add (Range, Type)

expression Required. A variable that represents a 'FormFields' collection.

Parameters

Name Required/Optional Data type Description
Range Required Range object The range where you want to add the form field. If the range isn't collapsed, the form field replaces the range.
Type Required WdFieldType The type of form field to add.

Return value

FormField

Example

This example adds a check box at the end of the selection, gives it a name, and then selects it.

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

See also

FormFields Collection Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.