MarkAllEntries Method

Microsoft Word Visual Basic

MarkAllEntries Method

       

Inserts an XE (Index Entry) field after all instances of the text in Range.

expression.MarkAllEntries(Range, Entry, EntryAutoText, CrossReference, CrossReferenceAutoText, BookmarkName, Bold, Italic)

expression   Required. An expression that returns an Indexes object.

Range   Required Range object. The range whose text is marked with an XE field throughout the document.

Entry   Optional Variant. The text you want to appear in the index, in the form MainEntry[:Subentry].

EntryAutoText   Optional Variant. The AutoText entry that contains the text you want to appear in the index (if this argument is specified, Entry is ignored).

CrossReference   Optional Variant. A cross-reference that will appear in the index.

CrossReferenceAutoText   Optional Variant. The name of the AutoText entry that contains the text for a cross-reference (if this argument is specified, CrossReference is ignored).

BookmarkName   Optional Variant. The bookmark name that marks the range of pages you want to appear in the index. If this argument is omitted, the number of the page that contains the XE field appears in the index.

Bold   Optional Variant. True to add bold formatting to page numbers for index entries.

Italic   Optional Variant. True to add italic formatting to page numbers for index entries.

Example

This example marks the selected text with TA fields throughout the active document and then updates the first index in the document. The entry text in the index matches the selected text.

If Selection.Type = wdSelectionNormal Then
    ActiveDocument.Indexes.MarkAllEntries _
        Range:=Selection.Range, _
        Entry:=Selection.Range.Text, Italic:=True
    ActiveDocument.Indexes(1).Update
End If