Finding and Marking Long Quotes

Written by Allen Wyatt (last updated May 14, 2026)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365


Chelsea works for an academic journal. Their house style indicates that quoted material that is more than 45 words should be treated as a block quote, in its own paragraph. Many authors ignore this requirement, so Chelsea needs to find the quotes, count the words, then manually break the quoted text into its own paragraph. She thinks that, perhaps, a macro that finds and marks the long quotes would be helpful to make her work easier.

Chelsea is correct—a macro to find and mark long quotes could be very helpful for her purposes. Finding long quotes is relatively easy in a macro, as it can do a wildcards-based search and figure out how many words are within a quote. If it is longer than 45 words, then the quote can be highlighted in yellow. Here's an example of such a macro:

Sub MarkLongQuotes()
    Dim rng As Range
    Dim quoteText As String
    Dim wordCount As Long
    Dim startPos As Long
    Dim endPos As Long

    Set rng = ActiveDocument.Range

    With rng.Find
        .ClearFormatting
        .Text = """*"""
        .MatchWildcards = True

        Do While .Execute
            quoteText = rng.Text
            quoteText = Replace(quoteText, """", "")
            wordCount = UBound(Split(quoteText, " ")) + 1
            If wordCount > 45 Then rng.HighlightColorIndex = wdYellow
            ' Move past this quote to find the next one
            rng.Collapse wdCollapseEnd
        Loop
    End With
End Sub

The macro works on the entire document and can run quite fast. It uses wildcard searching to find anything between enclosing quote marks, and then checks the length of what is found. For simple documents, it should be sufficient. The biggest drawback, though, is if your document uses smart quotes.

This distinction between straight and smart quote marks is critical because doing a manual find and replace doesn't differentiate between them—searching for a quote mark will match to a straight quote mark, an opening smart quote mark, or a closing smart quote mark. Not so in a macro, where searching for a straight quote (as is done in the foregoing macro) will only match straight quotes. It is possible to rewrite the macro to pay attention to smart quotes, but the issue becomes even more complex if the paper being checked could mix smart and straight quotes. For instance, a quote may begin with a smart quote mark but end with a straight quote mark—or vice versa.

Consider, then, the following two macros. There are two because the helper function (the second macro) is used strictly to locate the next quote mark of any type and return that character position to the main macro.

Sub MarkLongQuotes()
    Dim docEnd As Long
    Dim searchStart As Long
    Dim quoteRange As Range
    Dim openPos As Long
    Dim closePos As Long
    Dim changeCount As Long

    docEnd = ActiveDocument.Range.End
    searchStart = ActiveDocument.Range.Start

    changeCount = 0
    Do While searchStart < docEnd
        ' Find first quote mark, straight or smart
        openPos = NextQuotePos(searchStart, docEnd, ChrW(8220))
        If openPos <> -1 Then
            ' Find next quote mark, straight or smart
            closePos = NextQuotePos(openPos + 1, docEnd, ChrW(8221))
            If closePos > openPos Then
                ' Get word count
                Set quoteRange = ActiveDocument.Range(openPos, closePos + 1)
                If (quoteRange.Words.Count - 2) > 45 Then
                    ' Mark quote
                    quoteRange.HighlightColorIndex = wdYellow
                    changeCount = changeCount + 1
                End If
                searchStart = closePos + 1
            Else
                searchStart = docEnd
            End If
        Else
            searchStart = docEnd
        End If
    Loop
    MsgBox "Marked " & changeCount & " long quotes"
End Sub
Private Function NextQuotePos(StartPos As Long, EndPos As Long, _
  SmartQuote As String) As Long
    Dim rngStraight As Range
    Dim rngSmart As Range
    Dim straightPos As Long
    Dim smartPos As Long

    straightPos = -1
    smartPos = -1

    ' Find next straight quote
    Set rngStraight = ActiveDocument.Range(StartPos, EndPos)

    With rngStraight.Find
        .ClearFormatting
        .Text = """"
        .MatchWildcards = False
        .Wrap = wdFindStop

        If .Execute Then
            straightPos = rngStraight.Start
        End If
    End With

    ' Find next smart quote
    Set rngSmart = ActiveDocument.Range(StartPos, EndPos)

    With rngSmart.Find
        .ClearFormatting
        .Text = SmartQuote
        .MatchWildcards = False
        .Wrap = wdFindStop

        If .Execute Then
            smartPos = rngSmart.Start
        End If
    End With

    ' Return earliest match
    If straightPos = -1 And smartPos = -1 Then
        NextQuotePos = -1
    ElseIf smartPos = -1 Or _
      (straightPos <> -1 And straightPos < smartPos) Then
        NextQuotePos = straightPos
    Else
        NextQuotePos = smartPos
    End If
End Function

The majority of the necessary code is in the helper function, determining where the next quote mark is located. When the function is called, it is passed three parameters—the start of the search area, the end of the search area, and whether an opening smart quote or closing smart quote is expected. (The function doesn't need a specification for a straight quote mark; that character is always the same.)

Finally, this version of the macro also displays a message box that indicates how many long quotes were marked in the document.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13983) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 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

Inserting Footnotes Using Custom Footnote Marks

Automatic footnotes are easy to insert in Word documents. The default settings are usually fine for most projects. ...

Discover More

Importing Excel Information Into Chart

Microsoft Graph is great for displaying charts in a document, without the need to actually use Excel. However, your data ...

Discover More

Shortcut Key to Delete a Paragraph

There are numerous ways you can delete paragraphs as you are editing your document. This tip looks at a couple of the ...

Discover More

Do More in Less Time! An easy-to-understand guide to the more advanced features available in the Microsoft 365 version of Word. Enhance the quality of your documents and boost productivity in any field with this in-depth resource. Complete your Word-related tasks more efficiently as you unlock lesser-known tools and learn to quickly access the features you need. Check out Microsoft 365 Word For Professionals For Dummies today!

More WordTips (ribbon)

Getting the Proper Type of Ellipses

Type three periods in a row, and the AutoCorrect feature in Word kicks in to exchange that sequence for a special ...

Discover More

Moving an Entire Page

If you are new to using Word, you may wonder if there is an easy way to move pages around in the document. Word, though, ...

Discover More

Deleting All Text in Linked Text Boxes

Word allows you to place text in multiple text boxes and have that text flow from one text box to another. 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 three less than 3?

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.