Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Finding Long Sentences.
Written by Allen Wyatt (last updated July 12, 2025)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365
Bruce is looking for some way to have Word automatically mark long sentences in a document. For instance, he may want to have those sentences with more than 20 words marked in some color so that they are easily located.
Fortunately, Word maintains a Sentences collection, accessible through VBA, that consists of each sentence in a document. You can examine each item in this collection (each individual sentence) to determine if it is longer than your desired length. The following macro provides an example of how this is done.
Sub MarkLong1()
Dim iMyCount As Integer
Dim iWords As Integer
If Not ActiveDocument.Saved Then
ActiveDocument.Save
End If
iWords = 20 ' target word count
iMyCount = 0
For Each MySent In ActiveDocument.Sentences
If MySent.Words.Count > iWords Then
MySent.Font.Color = wdColorRed
iMyCount = iMyCount + 1
End If
Next
MsgBox iMyCount & " sentences longer than " & _
iWords & " words."
End Sub
Notice that the macro starts by saving the document. This is done because long sentences are going to be formatted as red text, and saving makes sure you have a "pre-change" version saved. Each sentence is examined, and if it is longer than the desired length (defined by the variable iWords) then the sentence is changed to a red font color. This makes it easy to examine the document and discover which sentences exceed the length you specified.
There is a drawback to this macro, though: The .Count property for the Words collection counts punctuation as individual words. Thus, the sentence "Really, she asked." would have a count of 5 words, instead of the 3 expected, because there are two punctuation marks. If you don't want punctuation marks included in figuring out the sentence lengths, then the macro needs to be lengthened just a bit:
Sub MarkLong2()
Dim iMyCount As Integer
Dim iWords As Integer
Dim MySent As Range
Dim iWordCount As Integer
Dim sPunc As String
Dim J As Integer
iWords = 20 ' target word count
sPunc = ".,?!;:-" ' don't count these as words
iMyCount = 0
For Each MySent In ActiveDocument.Sentences
If MySent.Words.Count > iWords Then
iWordCount = 0
For J = 1 To MySent.Words.Count
If InStr(sPunc, Trim(MySent.Words(J))) = 0 Then
iWordCount = iWordCount + 1
End If
Next J
If iWordCount > iWords Then
MySent.Font.Color = wdColorRed
iMyCount = iMyCount + 1
End If
End If
Next MySent
MsgBox iMyCount & " sentences longer than " & _
iWords & " words."
End Sub
In this version, if the .Count property is greater than iWords, then a trimmed version of each word in the sentence is compared against a string of punctuation characters (sPunc). Only if the word is not within the punctuation string is it counted. It is this secondary count (iWordCount) that is finally compared against iWords and, if it is greater, the sentence is formatted as red.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11909) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. You can find a version of this tip for the older menu interface of Word here: Finding Long Sentences.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2019. Spend more time working and less time trying to figure it all out! Check out Word 2019 For Dummies today!
If you know the character codes for some characters of interest, you can use those codes to do lots of tasks. This tip ...
Discover MoreWhen creating a document, if can be frustrating to have a blank page somehow appear at the end of the document. If you ...
Discover MoreWhen working in Draft or Normal view, you may want to view the area just to the left of the document's left margin. ...
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 © 2025 Sharon Parq Associates, Inc.
Comments