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
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.