Fields.Add Method

Adds a Field object to the Fields collection.

Namespace:  Microsoft.Office.Interop.Word
Assembly:  Microsoft.Office.Interop.Word (in Microsoft.Office.Interop.Word.dll)

Syntax

'Declaration
Function Add ( _
    Range As Range, _
    ByRef Type As Object, _
    ByRef Text As Object, _
    ByRef PreserveFormatting As Object _
) As Field
'Usage
Dim instance As Fields
Dim Range As Range
Dim Type As Object
Dim Text As Object
Dim PreserveFormatting As Object
Dim returnValue As Field

returnValue = instance.Add(Range, Type, _
    Text, PreserveFormatting)
Field Add(
    Range Range,
    ref Object Type,
    ref Object Text,
    ref Object PreserveFormatting
)

Parameters

  • Type
    Type: System.Object%
    Optional Object. Can be any WdFieldType constant. For a list of valid constants, consult the Object Browser. The default value is wdFieldEmpty.
  • Text
    Type: System.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
    Type: System.Object%
    Optional Object. True to have the formatting that's applied to the field preserved during updates.

Return Value

Type: Microsoft.Office.Interop.Word.Field

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 method and the Add method for the FormFields collection.

See Also

Reference

Fields Interface

Fields Members

Microsoft.Office.Interop.Word Namespace