Loading
Word.Tips.Net WordTips (Menu Interface)

Intelligent Title Case

Word contains a couple of different ways that you can adjust the case of selected text. If you are using Word 2007 you can make sure the Home tab of the ribbon is displayed and then clicking the Change Case tool in the Font group. If you are using an older version of Word you can click Format | Change Case to display the Change Case dialog box.

Either way, you'll see a list of different ways in which Word 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 contents of sTest are 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.

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 versions: 97 | 2000 | 2002 | 2003 | 2007

Related Tips:

Tremendous Table Tips! We often take tables for granted, but Word includes some very powerful ways you can present your tabular data. Discover how to make your tables better, easier to understand, and more effective. Check out WordTips: Terrific Tables today!

 

Comments for this tip:

Bert    03 Apr 2013, 03:53
Clever solution. Thanks. Just FYI, for titles, it's not really "short" words that should be lower case. It's any preposition, conjunction, or article, so your list might look something like this:
" a an the and but or nor with as of for up in by to from about against across "
There are no doubt others that don't spring to mind. Also, some of these may function as other parts of speech, so sometimes they should be capitalized and sometimes not. A little manual tweaking may occasionally be needed, but your approach should take care of most of the work.

Also, if you frequently have titles with abbreviations or other "words" that should be all caps, you could use a similar approach and check for those after checking for the lower case words. You might have another list like this: " US NASA NYC NCAA " (or whatever terms you frequently encounter).
Slate Grey    04 Feb 2013, 14:46
Word needs this ability (proper title case) very badly. Please note, however, that "is" is a verb and should be capitalized in title case. Also, in addition to the first word of the title, the last word of the title is always capitalized no matter what it is. The list of words the macro leaves lower-case is easy enough to modify, but what about the "last word" rule? e.g., "There Is an Investigation and We Are All In" should be correct.
josh    04 Dec 2012, 02:01
this is awesome! ....but I'm stuck: I'm trying to change all text that have header styles in my (huge dissertation) document. I have a macro that selects all header text, but when I run this macro, it doesn't change. I've also tried it with kutools, which allows me to select all headers as a single selection, and that doesn't work either.

Perhaps this doesn't work with noncontiguous selections? Any suggesetions how to fix that?
Stephen Goldborough    14 Sep 2012, 18:32
Works in Word 2010 too.. thank you.

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 2+3? (To prevent automated submissions and spam.)
 
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2013)

Family

Gardening

Health

Home Improvement

Legal Help

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

School and Schooling

Weddings

WindowsTips

WordTips (Word 97–2003)

WordTips (Word 2007–2013)

Our Products

Premium Newsletters

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2013 Sharon Parq Associates, Inc.