Creating Many Index Entries at Once

by Allen Wyatt
(last updated September 14, 2019)

1

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 Office 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

Nudging an Equation

You can adjust where an equation is printed by moving it minute amounts in any direction.

Discover More

Nudging a Table

When laying out a page, you often need to move objects around to get them into just the right position. Word allows you ...

Discover More

Freezing Both Rows and Columns

When you are working in a worksheet, you may want to freeze the rows at the top or left of the worksheet. Excel provides ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (ribbon)

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

Understanding Master and Subdocuments

Most people use Word to create regular documents that you edit, view, and print. The program also allows you to create a ...

Discover More

Mass Search and Replace

If you need to change information in dozens or even hundreds of documents, the task can seem insurmountable. Here's a way ...

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}] 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 four more than 9?

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.

Newest Tips
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.