Share via


DocumentBase.Fields Property

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

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property Fields As Fields
    Get
public Fields Fields { get; }

Property Value

Type: Microsoft.Office.Interop.Word.Fields
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 Sub DocumentFields()
    Dim Type As Object = Word.WdFieldType.wdFieldDate
    Me.Paragraphs(1).Range.InsertParagraphAfter()
    Me.Fields.Add(Me.Paragraphs(1).Range, Type)
End Sub
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);
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace