DocumentBase.Fields Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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