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: Intelligent Title Case.

Intelligent Title Case

Written by Allen Wyatt (last updated February 22, 2020)
This tip applies to Word 97, 2000, 2002, and 2003


Word contains a couple of different ways that you can adjust the case of selected text. One way is to click Format | Change Case to display the Change Case dialog box. Word lists different ways in which it can adjust the case of your text. One of the most common case changes is title case. This type of change results in each word of the selected text being uppercase, while the rest of the letters are in lowercase. The only problem with this is that Word is rather indiscriminate in what it capitalizes. For instance, if you select the text "this is a test" and then use the Change Case dialog box to change the text to title case, you end up with "This Is A Test." Common rules of capitalization, however, would dictate that the "short" words ("is" and "a") should not be capitalized.

This is where a macro comes in handy. You can create a macro to intelligently apply title case to a text selection. The macro can be programmed so that it ignores a specific set of words while doing its work. Consider the following macro:

Sub TitleCase()
    Dim lclist As String
    Dim wrd As Integer
    Dim sTest As String

    ' list of lowercase words, surrounded by spaces
    lclist = " of the by to this is from a "

    Selection.Range.Case = wdTitleWord

    For wrd = 2 To Selection.Range.Words.Count
        sTest = Trim(Selection.Range.Words(wrd))
        sTest = " " & LCase(sTest) & " "
        If InStr(lclist, sTest) Then
            Selection.Range.Words(wrd).Case = wdLowerCase
        End If
    Next wrd
End Sub

When you select some text and run this macro, the first thing it does is to change the text to Word's standard title case. It then steps through the words in the selection (Word makes the words available in the Words collection), examining each one. Each word is extracted and placed in the sTest variable, which then is converted to lowercase. The content of sTest is then checked against the lclist string to see if there is a match. If there is, then the word in the original text is converted to lowercase.

The key to the macro is the lclist string. This string contains a list of words that you want to always appear in lowercase. These words are surrounded by spaces—including the first and last words of the string. When the sTest comparison is done, sTest contains a leading and trailing space so that successful matches can be made. (The spaces are included so that there are no mistakes in word matching, for instance matching "he" to a part of "the".)

Note, as well, that the comparison portion of the macro doesn't pay attention to the first word in the text selection. This word is assumed to be the first word of a phrase or sentence, which should always start with an uppercase character.


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 (215) 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: Intelligent Title Case.

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


Inserting Custom Properties with Fields

Using File | Properties you can specify different information to be stored with your document. If you create your own ...

Discover More

Countering Compressed Columns

If you open a workbook and find that the width of some of your columns has been changed, the discovery can be ...

Discover More

Averaging without Hidden Cells

Grabbing an average of a range of cells is easy using Excel functions. If you want that average to ignore hidden cells ...

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 (menu)

Animating Your Text

Want to make your text shimmer and dance on the screen? Depending on your version of Word you can easily add snazzy ...

Discover More

Placing Numbers Over Other Numbers

Sometimes you need to create text that isn't as "linear" as you might expect. For instance, you may need to put some text ...

Discover More

Automatically Using Smart Quotes

As a way to make your documents look more professional, Word can utilize "smart quotes" for both quote marks and ...

Discover More

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

View most recent newsletter.


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 one less than 8?

2023-06-13 15:51:46


I love this macro, but I noticed today that it doesn't work when I run it on text in a table cell. For some reason, the value of Selection.Range.Words.Count is returned as 1 no matter how many words are in the selection range. However, if I take the text string out of the table, the macro works correctly. Anyone know why that would be or how to fix it?

2021-01-29 01:54:47

Lee Quinn

Thanks Ken, appreciate it! I'm still learning :)

2021-01-28 05:47:35

Ken Endacott


Your macro goes into an endless loop if Track Changes and Show Markup are on. This could be avoided by inserting after the Dim statements:

ActiveDocument.TrackRevisions = False
ActiveWindow.View.ShowRevisionsAndComments = False

Editor’s clients often specify that any changes be highlighted using Track Changes. Neither Allen’s or Lee’s macros will do that.

2021-01-27 20:13:34

Lee Quinn

for what it's worth, here's my take - thanks to Allen for the inspiration :)

Private Sub Tools_Set_Heading_Title_Case()
' affects ALL document content
' set expected 'proper' case for each heading
' find and set upper case where required
' find and set lower case where required
' reapply style to heading in case someone originally created the style as 'all caps'/'small caps'
' as we still want to see the 'proper' case in the navigation pane
Dim objStyle As Style
Dim arrTargetStyles(), arrTargetAllUpperCaseWords(), arrTargetAllLowerCaseWords()
Dim varCounter As Variant, arrUWord As Variant, arrLWord As Variant

arrTargetStyles = Array("Heading 1", "Heading 2", "Heading 3", "Heading 4")
arrTargetAllUpperCaseWords = Array("AS ", "CBTS", "CF", "CPU", "HMI", "HSTS", "LDS", "NTP", "PLC", "RCA", "RS LDS", "RS-LDS", "SD", "VSS", "WMS")
arrTargetAllLowerCaseWords = Array(" and ", " for ", " of ", " on ", " the ", " to ")

For Each varCounter In arrTargetStyles
With Selection.Find
.Wrap = wdFindContinue
.Forward = True
.Format = True
.MatchWildcards = False
.Text = ""
.Style = ActiveDocument.Styles(varCounter)

While .found
'Debug.Print "Configuring "; varCounter; " "; Selection.Text
' set title case
Selection.Range.Case = wdTitleWord
' find and fix upper case matching words
For Each arrUWord In arrTargetAllUpperCaseWords
If InStr(1, Selection.Text, arrUWord, vbTextCompare) > 0 Then
Selection.Text = Replace(Selection.Text, arrUWord, UCase(arrUWord), 1, 1, vbTextCompare)
End If
Next arrUWord
' find and fix lower case matching words
For Each arrLWord In arrTargetAllLowerCaseWords
If InStr(1, Selection.Text, arrLWord, vbTextCompare) > 0 Then
Selection.Text = Replace(Selection.Text, arrLWord, LCase(arrLWord), 1, 1, vbTextCompare)
End If
Next arrLWord
' reapply style to heading
Selection.Style = varCounter
Selection.Collapse Direction:=wdCollapseEnd
End With
Next varCounter

Set objStyle = Nothing
Set varCounter = Nothing
Erase arrTargetStyles
Erase arrTargetAllUpperCaseWords
Erase arrTargetAllLowerCaseWords

Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst

'Debug.Print "Finished!"
End Sub

2020-05-25 13:27:44

Jim Dandy

I'm trying to do this for PowerPoint but I can only find a way to apply title case to slide titles. I cannot seem to figure out the proper way to title-case selected text like that which exists in the text boxes and content sections.

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.


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.