Share via


DocumentBase.Indexes 屬性

取得 Indexes 集合,表示文件中的所有索引。

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

語法

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

屬性值

型別:Microsoft.Office.Interop.Word.Indexes
Indexes 集合,表示文件中的所有索引。

範例

下列程式碼範例會將文字加入至第一個段落,並且插入索引項目。 然後程式碼會在第二個段落加入索引。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentIndexes()

    Me.Paragraphs(1).Range.Text = "This is sample text." & vbLf
    Dim entry As Object = Me.Paragraphs(1).Range.Text
    Dim headingSeparator As Object = False

    Me.Indexes.MarkEntry(Me.Paragraphs(1).Range, entry)

    Dim Type As Object = Word.WdIndexType.wdIndexRunin
    Me.Indexes.Add(Me.Paragraphs(2).Range, headingSeparator, , Type)

End Sub 
private void DocumentIndexes()
{

    this.Paragraphs[1].Range.Text = "This is sample text." + "\n";
    object entry = this.Paragraphs[1].Range.Text;
    object headingSeparator = false;

    this.Indexes.MarkEntry(this.Paragraphs[1].Range,
        ref entry, ref missing, ref missing, ref missing,
        ref missing, ref missing, ref missing, ref missing);


    object Type = Word.WdIndexType.wdIndexRunin;
    this.Indexes.Add(this.Paragraphs[2].Range, 
        ref headingSeparator, ref missing, ref Type,
        ref missing, ref missing, ref missing, 
        ref missing);
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間