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.
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!
Type three periods in a row, and the AutoCorrect feature in Word kicks in to exchange that sequence for a special ...
Discover MoreIf 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 MoreWord allows you to place text in multiple text boxes and have that text flow from one text box to another. This tip ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2026 Sharon Parq Associates, Inc.
Comments