Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Controlling the Format of Cross-References.

Controlling the Format of Cross-References

Written by Allen Wyatt (last updated April 20, 2024)
This tip applies to Word 97, 2000, 2002, and 2003


Stephen asked if it is possible to control the format of cross-references inserted by Word. When he inserts a label and number such as Table 1 or Figure 12, he wants the label lowercase (table, figure) and a non-breaking space between the label and the number.

There is no way to control this type of cross-reference formatting in Word. Obviously you can change the cross-references manually after placing them, but whenever you update fields the original Word-chosen format will be used for them. There are a couple of macro-based solutions you can try. The first solution will change the actual field codes used for the field:

Sub FieldRefChanges1()
    On Error Resume Next
    Dim oStoryRng As Range
    Dim oFld As Field

    For Each oStoryRng In ActiveDocument.StoryRanges
        For Each oFld In oStoryRng.Fields
            If oFld.Type = wdFieldRef And oFld.Result.Words.Count <= 2 Then
                'add format switch with lowercase option to field codes
                oFld.Code.Text = oFld.Code.Text & "\* lower "
                'updates the field results to display the new format
                oFld.Update
            End If
        Next oFld
    Next oStoryRng
End Sub

The macro includes a couple of nested For loops. The first one steps through each story in the document, and the second goes through each field in each story. An If statement is then used to make sure that the field is a REF field (the kind used for cross-references) and that the result of the field is two or fewer words (as in Table 1 or Figure 12).

If these criteria are met, then the macro makes a change to the actual field code, adding the switch that results in the field being displayed in lowercase.

There are a couple of drawbacks to this macro. First, if you run it multiple times, the \* lower switch is added to the REF fields multiple times. Second, the macro doesn't change the space in the field results to a non-breaking space.

To overcome both problems, just modify the macro so that it automates the manual process you would go through to change the macro results.

Sub FieldRefChanges2()
    On Error Resume Next
    Dim oStoryRng As Range
    Dim oFld As Field
    Dim sTemp As String
    Dim J As String

    For Each oStoryRng In ActiveDocument.StoryRanges
        For Each oFld In oStoryRng.Fields
            If oFld.Type = wdFieldRef And oFld.Result.Words.Count <= 2 Then
                sTemp = oFld.Result.Text
                sTemp = LCase(sTemp)
                J = InStr(sTemp, " ")
                sTemp = Left(sTemp, J - 1) & Chr(160) & _
                  Mid(sTemp, J + 1, Len(sTemp) - J)
                oFld.Result.Text = sTemp
            End If
        Next oFld
    Next oStoryRng
End Sub

This macro is essentially the same as the previous one, except that it works strictly with the result text for the field. The text is assigned to the sTemp variable, which is then converted to lowercase. The position of the space is determined, and it is replaced with a non-breaking space. The result is then stuffed back into the result text for the field.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (141) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Controlling the Format of Cross-References.

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

Freezing a Table

Tired of Word changing the dimensions of table cells to accommodate what you place in those cells? You can instruct Word ...

Discover More

Improving Text Sharpness with ClearType

Ever notice that even with a fancy new monitor, text can still look a bit muddy on the screen. You can use ClearType ...

Discover More

Unbreakable Formula References to Worksheets

Excel allows you, in your formulas, to include references to cells on other worksheets. Those references include the name ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (menu)

Cross-Referencing to Line Numbers

Wouldn't it be nice to be able to do cross-referencing to line numbers within a document? Word doesn't have a built in ...

Discover More

Condensing Figure Caption References

Word can automatically add captions to your figures. You can then reference those captions from within your document. If ...

Discover More

Inserting Page Number Cross-References

Want to insert a dynamic cross-reference to a particular page number? It's easy to do following the steps in this tip.

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 two more than 7?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon 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.