MarkEntry Method

Microsoft Word Visual Basic

Show All

MarkEntry Method

       

MarkEntry method as it applies to the Indexes object.

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

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

expression   Required. An expression that returns an Indexes object.

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

Entry  Optional Variant. The text that appears in the index. 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.

Reading  Optional Variant.

MarkEntry method as it applies to the TablesOfContents and TablesOfFigures objects.

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

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

expression   Required. An expression that returns a TablesOfContents or TablesOfFigures object.

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

Entry  Optional Variant. The text that appears in the 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).

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.

Example

As it applies to the Indexes object.

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:=TrueEnd If

As it applies to the Table of Contents object.

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