Class Index (Word VBA)

The class Index represents a single index. The Index object is a member of the Indexes collection. The Indexes collection includes all the indexes in the specified document.

The main procedures of class Index are Delete and Indexes.Add


To use a Index class variable it first needs to be instantiated, for example

Dim idx as Index
Set idx = ActiveDocument.Indexes(Index:=1)

The following procedures can be used to set variables of type Index: Indexes.Add, Indexes.Item and Document.Indexes

For Each

Here is an example of processing the Index items in a collection.

Dim idx As Index
For Each idx In ActiveDocument.Indexes
Next idx


These are the main methods of the Index class

Delete - Deletes the specified index.


Indexes.Add - Returns an Index object that represents a new index added to a document.

Dim idx As Index
Set idx = ActiveDocument.Indexes.Add(Range:=)

Other Methods

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

ActiveDocument.Indexes.MarkAllEntries Range:=

Indexes.MarkEntry - Inserts an XE (Index Entry) field after the specified range. The method returns a Field object representing the XE field.

Dim fldMarkEntry As Field
Set fldMarkEntry = ActiveDocument.Indexes.MarkEntry(Range:=)


AccentedLetters true if the specified index contains separate headings for accented letters (for example, words that begin with "À" are under one heading and words that begin with "A" are under another).

ActiveDocument.Indexes(1).AccentedLetters = True

Filter returns or sets a value that specifies how Microsoft Word classifies the first character of entries in the specified Long. Can be one of the following wdIndexFilter constants.

ActiveDocument.Indexes(1).Filter = wdIndexFilterAiueo

HeadingSeparator returns or sets the text between alphabetical groups (entries that start with the same letter) in the index. Corresponds to the \h switch for an INDEX field.

ActiveDocument.Indexes(1).HeadingSeparator = wdHeadingSeparatorBlankLine

IndexLanguage returns or sets a WdLanguageID constant that represents the sorting language to use for the specified index.

ActiveDocument.Indexes(1).IndexLanguage = wdAfrikaans

NumberOfColumns sets or returns the number of columns for each page of an index.

ActiveDocument.Indexes(1).NumberOfColumns =

Parent returns an object that represents the parent object of the specified Index object.

Dim objParent As Object
Set objParent = ActiveDocument.Indexes(1).Parent

Range returns a Range object that represents the portion of a document that is contained within an index.

Dim rngRange As Range
Set rngRange = ActiveDocument.Indexes(1).Range

RightAlignPageNumbers true if page numbers are aligned with the right margin in an index.

ActiveDocument.Indexes(1).RightAlignPageNumbers = True

SortBy returns or sets the sorting criteria for the specified index.

ActiveDocument.Indexes(1).SortBy = wdIndexSortByStroke

TabLeader returns or sets the leader character between entries in an index and their associated page numbers.

ActiveDocument.Indexes(1).TabLeader = wdTabLeaderDashes

Type returns or sets the index type.

ActiveDocument.Indexes(1).Type = wdIndexIndent

Indexes.Count returns a Long that represents the number of indexes in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.Indexes.Count

Indexes.Format returns or sets a WdIndexFormat that represents the formatting for the indexes in the specified document.

ActiveDocument.Indexes.Format = wdIndexBulleted

Indexes.Parent returns an object that represents the parent object of the specified Indexes object.

Dim objParent As Object
Set objParent = ActiveDocument.Indexes.Parent