MarkEntry Method

Applies To

Indexes collection object, TablesOfContents collection object, TablesOfFigures collection object.

Description

Syntax 1: Inserts an XE (Index Entry) field after the specified range. The XE field is returned as a Field object.

Syntax 2: Inserts a TC (Table of Contents Entry) field after the specified range. The TC field is returned as a Field object.

Syntax 1

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

Syntax 2

expression.MarkEntry(Range, Entry, EntryAutoText, TableID, Level)

expression Syntax 1: Required. An expression that returns an Indexes object.

Syntax 2: Required. An expression that returns a TablesOfContents or TablesOfFigures object.

Range Required Range object. The location of the entry. The XE or TC field is inserted after Range.

Entry Optional Variant. The text that appears in the index, table of contents, or table of figures. To indicate a subentry, include the main entry text and the subentry text, separated by a colon (:) (for example, "Introduction: The Product").

EntryAutoText Optional Variant. The AutoText entry name that includes text for the index, table of figures, or table of contents (Entry is ignored).

CrossReference Optional Variant. A cross-reference that will appear in the index (for example, "See Apples").

CrossReferenceAutoText Optional Variant. The AutoText entry name that contains the text for a cross-reference (CrossReference is ignored).

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

Bold Optional Variant. True to add bold formatting to the entry page numbers in the index.

Italic Optional Variant. True to add italic formatting to the entry page numbers in the index.

TableID Optional Variant. A one-letter identifier for the table of figures or table of contents item (for example, "i" for an "illustration").

Level Optional Variant. A level for the entry in the table of contents or table of figures.

See Also

AutoMarkEntries method, MarkAllEntries method.

Example

This example inserts an index entry after the selection in the active document. The subentry text is the text from the selection.

If Selection.Type = wdSelectionNormal Then
    ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, _
        Entry:="Introduction:" & Selection.Range.Text, Italic:=True
End If
This example inserts a table of contents entry that references the selected text. The text typed in the input box appears in the table of contents. A table of contents that uses fields is then added at the beginning of the active document.

entryText = InputBox("Type entry text")
ActiveDocument.TablesOfContents.MarkEntry Range:=Selection.Range, _
    Entry:=entryText
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.TablesOfContents.Add Range:=myRange, UseFields:=True, UseHeadingStyles:=False