Modifica

Condividi tramite


Fields.Add(Range, Object, Object, Object) Method

Definition

Adds a Field object to the Fields collection.

public Microsoft.Office.Interop.Word.Field Add (Microsoft.Office.Interop.Word.Range Range, ref object Type, ref object Text, ref object PreserveFormatting);
abstract member Add : Microsoft.Office.Interop.Word.Range * obj * obj * obj -> Microsoft.Office.Interop.Word.Field
Public Function Add (Range As Range, Optional ByRef Type As Object, Optional ByRef Text As Object, Optional ByRef PreserveFormatting As Object) As Field

Parameters

Range
Range

Required Range object. The range where you want to add the field. If the range isn't collapsed, the field replaces the range.

Type
Object

Optional Object. Can be any WdFieldType constant. For a list of valid constants, consult the Object Browser. The default value is wdFieldEmpty.

Text
Object

Optional Object. Additional text needed for the field. For example, if you want to specify a switch for the field, you would add it here.

PreserveFormatting
Object

Optional Object. True to have the formatting that's applied to the field preserved during updates.

Returns

Remarks

This method returns the Field object at the specified range.

You cannot insert some fields (such as wdFieldOCX and wdFieldFormCheckBox) by using the Add method of the Fields collection. Instead, you must use specific methods such as the AddOLEControl(Object, Object, Object, Object, Object, Object) method and the Add method for the FormFields collection.

Applies to