Creating Many Index Entries at Once

Written by Allen Wyatt (last updated July 6, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


2

Justin is putting together a document that has many references that look like "ABC 12:34," and he wants to create index entries for all of them. He is able to use wildcards in Find and Replace to find these references, but he has not been able to find a way to create an index entry for each instance that is found.

One way to create the index you want is to rely on what Microsoft calls a "concordance file." This is nothing but a list of things you want indexed and an indication of how you want them indexed. Word then uses the concordance file as a guide in adding the index entries to your main document.

Let's look at the concordance file first. It is very simply constructed, containing nothing but a single two-column table. In the left column, each row should indicate a different term you want indexed in your main document. In Justin's case, he would need to list each unique "ABC 12:34" combination. In the right column each row would contain the index entry desired for the term to the left. In many cases this may mean that the right column simply repeats what is in the left, but it wouldn't necessarily if you want to specify different wording for the index entry or you want a subentry included. (If you want a subentry, you would use the main index entry followed by a colon and then the subentry.)

Once the concordance file is complete, save it away. Now you can open your main document and follow these steps:

  1. Display the References tab of the ribbon.
  2. Near the right side of the ribbon, in the Index group, click the Insert Index tool. Word displays the Index dialog box. (See Figure 1.)
  3. Figure 1. The Index dialog box.

  4. Click the AutoMark button. Word displays a dialog box that looks very similar to a standard Open dialog box.
  5. Use the tools in the dialog box to locate and select the concordance file you created.
  6. Click Open.

That's it; Word uses the contents of the concordance file as the guide for adding index entries to your main document. When it is done, you can insert your index wherever you want.

One thing I find helpful whenever I'm going to let Word perform some sort of mass operation on a document is to actually make sure I keep an extra copy of the document sitting around. Thus, before you apply the concordance file using the steps above, you might want to make a copy of your unaltered document. This is simply a safety precaution in case I, personally, messed something up in the concordance file.

If you don't want to go the route of creating a concordance file, you could use a macro to add the index entries. This is an example:

Sub CreateManyIndexEntries()
    Dim sFindPattern As String
    Dim sTemp As String

    ' Indicate the pattern to find
    sFindPattern = "^$^$^$ ^#^#:^#^#"

    ' Jump to beginning of document
    Selection.HomeKey Unit:=wdStory

    ' Find first instance of pattern
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = sFindPattern
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .IgnoreSpace = False
    End With
    Selection.Find.Execute

    While Selection.Find.Found
        ' Create what we want for index entry,
        ' ensuring that any colons are escaped out
        sTemp = Replace(Selection, ":", "\:")

        ' Create the actual index entry
        ActiveDocument.Indexes.MarkEntry _
          Range:=Selection.Range, _
          Entry:=sTemp, _
          EntryAutoText:="", _
          CrossReference:="", _
          CrossReferenceAutoText:="", _
          BookmarkName:="", _
          Bold:=False, _
          Italic:=False

        ' Set up next Find operation
        Selection.Collapse wdCollapseEnd
        Selection.Find.Execute
    Wend
End Sub

The macro jumps to the beginning of the document and finds the first instance of whatever is in the sFindPattern variable. As shown above, the variable contains a pattern—three letters followed by a space, then two digits, a colon, and two digits. (This is the pattern that Justin specified.) If a match is found, then an index entry is created that matches whatever was found. The index entry is inserted in the document and then the next occurrence of the pattern is looked for. This is repeated for each instance of the pattern in the document.

The macro approach is more of a brute-force method of creating the index entries. That's because it isn't as flexible as using the concordance file; it doesn't handle creating index entries that are different from what you are searching for, nor does it handle subentries.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13674) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Automatic AutoCorrect Exceptions for Beginning Sentences

When automatically capitalizing the beginning of sentences, Word relies on how you historically have done your typing. ...

Discover More

Making Pane Settings Persist

When you freeze panes in a worksheet, those panes should persist even though you save the workbook and reload it. There ...

Discover More

Removing All Text Boxes In a Document

Text boxes are a common element of many types of documents. At some point you may want to get rid of all the text boxes ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (ribbon)

Enforcing a Do-Not-Use Word List

Got a list of words you don't want to appear in your documents? There are a number of ways that you can make sure they ...

Discover More

Displaying the Navigation Pane

One of the viewing modes you can use for a document involves the use of the Navigation pane. This shows a quick outline ...

Discover More

Moving Master and Subdocuments

If you need to move master documents or subdocuments from one place to another on your computer, you have to keep in mind ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 2?

2020-08-24 11:55:46

Gregg

That's wonderful, but how do I mass-delete index fields made in error? I don't want to have a backup Word document for every possible step that I might mess up. Maybe there is a find-and-replace variant that operates on whether the found text is a field and changes that to not be a field?
And what happens to index fields that I've made manually -- are they deleted when a concordance file is applied?


2019-09-14 05:05:55

Mike Dresel

This is a great tip. I will definitely be able to use it.

One general comment about "how to do X" instructions. Not everyone reads the entire list before starting, so anything that goes "Step 1; Step 2; Step 3; But first, do this" can be difficult/disasterous. I would recommend that the (very useful) suggestion to back up the document should come before the indexing instructions
Mike - who had written way too many instructions.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.