DocumentBase.Fields 屬性

取得唯讀的 Fields 集合,其中含有主文字大綱中的欄位。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

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

屬性值

型別:Microsoft.Office.Interop.Word.Fields
唯讀的 Fields 集合,表示主文字大綱中的欄位。

範例

下列程式碼範例會將日期欄位加入至文件中的第一個段落。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

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 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間