Add Method (Fields Collection)

See Also         Example         Applies To

Adds a field at the specified range.

Syntax

expression.Add(Range, Type, Text, PreserveFormatting)

expression   Required. An expression that returns a Fields object.

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

Type   Optional Variant. The kind of field to be added. Can be one of the following WdFieldType constants:

wdFieldAddin

wdFieldAdvance

wdFieldAsk

wdFieldAuthor

wdFieldAutoNum

wdFieldAutoNumLegal

wdFieldAutoNumOutline

wdFieldAutoText

wdFieldAutoTextList

wdFieldBarCode

wdFieldComments

wdFieldCompare

wdFieldCreateDate

wdFieldData

wdFieldDatabase

wdFieldDate

wdFieldDDE

wdFieldDDEAuto

wdFieldDocProperty

wdFieldDocVariable

wdFieldEditTime

wdFieldEmbed

wdFieldEmpty

wdFieldExpression

wdFieldFileName

wdFieldFileSize

wdFieldFillIn

wdFieldFootnoteRef

wdFieldFormCheckBox

wdFieldFormDropDown

wdFieldFormTextInput

wdFieldFormula

wdFieldGlossary

wdFieldGotoButton

wdFieldHTMLActiveX

wdFieldHyperlink

wdFieldIf

wdFieldImport

wdFieldInclude

wdFieldIncludePicture

wdFieldIncludeText

wdFieldIndex

wdFieldIndexEntry

wdFieldInfo

wdFieldKeyWord

wdFieldLastSavedBy

wdFieldLink

wdFieldListNum

wdFieldMacroButton

wdFieldMergeField

wdFieldMergeRec

wdFieldMergeSeq

wdFieldNext

wdFieldNextIf

wdFieldNoteRef

wdFieldNumChars

wdFieldNumPages

wdFieldNumWords

wdFieldOCX

wdFieldPage

wdFieldPageRef

wdFieldPrint

wdFieldPrintDate

wdFieldPrivate

wdFieldQuote

wdFieldRef

wdFieldRefDoc

wdFieldRevisionNum

wdFieldSaveDate

wdFieldSection

wdFieldSectionPages

wdFieldSequence

wdFieldSet

wdFieldSkipIf

wdFieldStyleRef

wdFieldSubject

wdFieldSubscriber

wdFieldSymbol

wdFieldTemplate

wdFieldTime

wdFieldTitle

wdFieldTOA

wdFieldTOAEntry

wdFieldTOC

wdFieldTOCEntry

wdFieldUserAddress

wdFieldUserInitials

wdFieldUserName


The default value is wdFieldEmpty.

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

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

Remarks

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.