DocumentBase.Fields Property

Definition

Gets a read-only Fields collection that contains the fields in the main text story.

public:
 property Microsoft::Office::Interop::Word::Fields ^ Fields { Microsoft::Office::Interop::Word::Fields ^ get(); };
public Microsoft.Office.Interop.Word.Fields Fields { get; }
member this.Fields : Microsoft.Office.Interop.Word.Fields
Public ReadOnly Property Fields As Fields

Property Value

A read-only Fields collection that represents all the fields in the main text story.

Examples

The following code example adds a date field to the first paragraph in the document. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentFields()
{
    object Type = Word.WdFieldType.wdFieldDate;
    this.Paragraphs[1].Range.InsertParagraphAfter();
    this.Fields.Add(this.Paragraphs[1].Range, ref Type, ref missing, ref missing);
}
Private Sub DocumentFields()
    Dim Type As Object = Word.WdFieldType.wdFieldDate
    Me.Paragraphs(1).Range.InsertParagraphAfter()
    Me.Fields.Add(Me.Paragraphs(1).Range, Type)
End Sub

Applies to