Add Method (Indexes Collection)

Applies To

Indexes collection object.

Description

Adds a new index to a document.

Syntax

expression.Add(Range, HeadingSeparator, RightAlignPageNumbers, Type,
ú NumberOfColumns, AccentedLetters)

expression Required. An expression that returns an Indexes object.

Range Required Range. The range where you want the index to appear. The index replaces the range, if the range isn't collapsed.

HeadingSeparator Optional Variant. The text between alphabetic groups (entries that start with the same letter) in the index. Can be one of the following WdHeadingSeparator constants: wdHeadingSeparatorBlankLine, wdHeadingSeparatorLetter, wdHeadingSeparatorLetterFull, wdHeadingSeparatorLetterLow, or wdHeadingSeparatorNone.

RightAlignPageNumbers Optional Variant. True to align page numbers with the right margin.

Type Optional Variant. Specifies whether subentries are on the same line (run-in) as the main entry or on a separate line (indented) from the main entry. Can be either of the following WdIndexType constants: wdIndexIndent or wdIndexRunin.

NumberOfColumns Optional Variant. The number of columns for each page of the index. Specifying 0 (zero) sets the number of columns in the index to the same number as in the document.

AccentedLetters Optional Variant. True to include separate headings for accented letters in the index (for example, words that begin with "À" and words that begin with "A" are listed under separate headings).

Remarks

An index is built from XE (Index Entry) fields in a document. Use the MarkEntry method to mark index entries to be included in an index.

See Also

AutoMarkEntries method, Indexes Collection object, MarkAllEntries method, MarkEntry method.

Example

This example marks an index entry, and then it creates an index at the end of the active document.

ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, Entry:="My Entry"
Set MyRange = ActiveDocument.Content
MyRange.Collapse Direction:=wdCollapseEnd
ActiveDocument.Indexes.Add Range:=MyRange, Type:=wdIndexRunin