Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, and 2016. 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.

Finding Long Sentences

by Allen Wyatt
(last updated May 16, 2016)


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 Mark_Long()
    Dim iMyCount As Integer
    Dim iWords As Integer

    If Not ActiveDocument.Saved Then
    End If

    'Reset counter
    iMyCount = 0 

    'Set number of words
    iWords = 20

    For Each MySent In ActiveDocument.Sentences
        If MySent.Words.Count > iWords Then 
            MySent.Font.Color = wdColorRed
            iMyCount = iMyCount + 1
        End If
    MsgBox iMyCount & " sentences longer than " & _
      iWords & " words."
End Sub

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

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, and 2016. You can find a version of this tip for the older menu interface of Word here: Finding Long Sentences.

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


Hiding Smart Tags

If you don't want to see Smart Tags displayed in your document, you can instruct Word to hide them. Here's how to make ...

Discover More

Setting a Default File Format

Excel normally saves workbooks using a default file format that is peculiar to your version of the program. You can ...

Discover More

Hiding Rows Based on Two Values

It's easy to use filtering to hide rows based on the value in a cell, but how do you hide rows based on the values in two ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Displaying Spaces in a Document

Seeing where every space is within a document can be very helpful in polishing your editing. Here's how to make those ...

Discover More

Using Go To with a Percentage

Need to jump a certain percentage of the way through a document? You can do it using the familiar Go To tab of the Find ...

Discover More

Removing Tabs Used to Indent a Paragraph

You get a document from a colleague and you notice that each paragraph starts with a tab character. Here are a couple of ...

Discover More

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


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}] 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 seven more than 3?

2018-06-22 16:24:48

James M. Hopkins

Was the question on getting rid of the red text answered?

I inserted the code after the save that starts with

Set myRange = ActiveDocument.Content and additional code

Is this supposed to be before the End If or after it?

I entered it before the End If and got a strange result.

Also entered Dim MySent As Object

2016-11-23 07:37:59


Thanks for this, works great!

If I then go and change some of the sentences to less than 20 words and run the macro again, is there any way to change the sentences that are less than 20 words back to black, rather than staying red?


2014-11-26 15:20:14

Darin Ramsey

This is very useful for us, as our group supports a large engineering organization on a Federal project. I've altered your macro to pull the average sentence length from the readability statistics, double it, and change those sentences red. Unfortunately, it appears to be counting punctuation as "words." In a document with an average sentence length of 20.3, a sentence with 37 words (according to the GUI) and five internal marks (a set of parentheses, a semicolon, and two commas) was going red until I removed four of the marks. Which four doesn't make any difference, so it seems to be counting all of them. Do you have any advice on getting the VBA word count to more accurately align with Word's GUI count? The changes in the code are as follows:

After the save, insert this:
Set myRange = ActiveDocument.Content
wordval = myRange.ReadabilityStatistics(6).Value

When setting the iWords value, use this:
iWords = wordval * 2

2013-12-18 02:32:27

Rochelle Fisher

We got an error on the first run, that MySent is not defined. Added: Dim MySent As Object

(At first, defined it as Sentences, but that caused other problems.)

2013-11-26 21:53:50


hi !
how do i get it to undo the red marks on my file ?
thanks !

2013-10-17 14:22:58

Mike Korner

Just wanted to say thanks for this Allen. It was helpful today.

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.

Newest Tips

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.