Capitalizing the First Letter after a Quote Mark

Written by Allen Wyatt (last updated August 7, 2021)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and 2021


Phil notes that Word is great at automatically capitalizing the first letter of sentences. However, he writes conversational fiction, which means he has a lot of sentences that begin with quote marks. Word won't automatically capitalize the first letter within a quote that starts a sentence, so Phil wonders if there is some setting that can correct this issue.

There is no setting in Word that will handle this situation. However, you could easily create a macro to make sure that the desired characters are uppercase. The macro could rely on the fact that you could use Find and Replace to do the work for you. Assuming that your back-and-forth dialogue results in the quotes beginning on their own paragraphs, you just need to search for a hard return, followed by a quote mark, and then followed by a letter. This could easily be replaced with the hard return, the quote mark, and the uppercase version of the letter. Here's an example of a macro that does this:

Sub QuoteCaps1()
    Dim J As Integer
    Dim sFind As String
    Dim sRep As String

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    For J = 97 To 122
        sFind = "^p" & Chr(34) & Chr(J)
        sRep = "^p" & Chr(34) & Chr(J - 32)

        With Selection.Find
            .Text = sFind
            .Replacement.Text = sRep
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    Next J
End Sub

The heart of the macro is the For...Next loop which steps through all the lowercase letters (ASCII codes 97 through 122) and puts together both the search and replace strings. The search string (stored in the sFind variable) consists of the hard return (^p) followed by a quote mark and then the lowercase character. The replace string (stored in the sRep variable) is the same, except it uses an uppercase character, calculated by subtracting 32 from the ASCII value of the lowercase character.

The macro effectively performs 26 find and replace operations on your document, but it does them very quickly. If your document is short, then the macro seems to run almost instantly. If your document is much longer, then it may take a few moments to run.

Perhaps, though, your dialogue doesn't always begin at the start of a paragraph, as in the following example:

Morris nodded his head. "of course it works that way."

If you want the macro to catch lowercase letters following any opening quote marks, then all you need to do is to modify the macro to exclude the "^p" that is added to the beginning of the sFind and sRep variables. That may have unintended consequences, however, if your dialogue is similar to this:

Morris lunged across the desk. "where is she," he demanded, "and is she OK?"

In this situation, the macro would capitalize both the "where" and the "and," though you probably don't want the "and" to be capitalized. If your prose may have such usage, you'll need a more complex macro, such as the following:

Sub QuoteCaps2()
    Dim J As Integer
    Dim K As Integer
    Dim sFind As String
    Dim sRep As String
    Dim sTerm As String

    sTerm = ".!?"

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    For J = 97 To 122
        sFind = "^p" & Chr(34) & Chr(J)
        sRep = "^p" & Chr(34) & Chr(J - 32)

        With Selection.Find
            .Text = sFind
            .Replacement.Text = sRep
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    Next J

    For J = 1 To Len(sTerm)
        For K = 97 To 122
            sFind = Mid(sTerm, J, 1) & " " & Chr(34) & Chr(K)
            sRep = Mid(sTerm, J, 1) & " " & Chr(34) & Chr(K - 32)

            With Selection.Find
                .Text = sFind
                .Replacement.Text = sRep
                .Forward = True
                .Wrap = wdFindContinue
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = False
                .MatchSoundsLike = False
                .MatchAllWordForms = False
            End With
            Selection.Find.Execute Replace:=wdReplaceAll
        Next K
    Next J
End Sub

This version of the macro still steps through and capitalizes quoted letters at the beginning of paragraphs, but then it starts doing searches for any quotes that start sentences. Note the use of the sTerm string, which contains characters that can end sentences—a period, an exclamation mark, and a question mark. (You can expand the number of sentence-terminating characters, if you'd like.) The macro steps through each of these characters and puts together both sFind and sRep variables that consist of the character, a space, a quote mark, and a lowercase letter. These are replaced with the uppercase equivalents.

As you can imagine, this macro will take just a bit longer to run. Why? Because where the first macro did 26 find and replace operations, this one does at least 104, and if you lengthen what is in the sTerm variable, each new character will add 26 additional find and replace operations.

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 (13893) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and 2021.

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

Adding Ampersands in Headers and Footers

Place an ampersand into the text of a page header or footer, and you might be surprised to see it missing in your ...

Discover More

Deleting a Bookmark

Create a bookmark and you may, at some future point, need to delete that bookmark. It's easy to do, as described in this tip.

Discover More

Calculating a Date Five Days before the First Business Day

Excel allows you to perform all sorts of calculations using dates. A good example of this is using a formula to figure ...

Discover More

Discover the Power of Microsoft Office This beginner-friendly guide reveals the expert tips and strategies you need to skyrocket your productivity and use Office 365 like a pro. Mastering software like Word, Excel, and PowerPoint is essential to be more efficient and advance your career. Simple lessons guide you through every step, providing the knowledge you need to get started. Check out Microsoft Office 365 For Beginners today!

More WordTips (ribbon)

Selecting the Entire Document with the Mouse

Want a quick way to select your entire document without taking your hand off the mouse? Try clicking away using the ...

Discover More

Non-breaking Em Dashes

Need an em dash to be "sticky" on both ends of the dash? Word doesn't provide such formatting, but there are a few ...

Discover More

Adding Parentheses

Need to add parentheses around some word or phrase? Here's a quick macro that makes this simple edit in one step.

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 0 + 1?

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