DocumentBase.Fields 属性

定义

获取一个只读 Fields 集合,该集合包含主文档内容中的字段。

public Microsoft.Office.Interop.Word.Fields Fields { get; }

属性值

Fields

一个只读 Fields 集合,表示主文档内容中的所有字段。

示例

下面的代码示例将一个日期字段添加到文档中的第一个段落。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

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

适用于