Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Finding Long Sentences.

Finding Long Sentences

by Allen Wyatt
(last updated June 8, 2015)


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 (3381) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) 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. ...


Intelligible Names for Macros

The names you use for macros can affect what you see when you add those macros to a toolbar. This tip explains how you ...

Discover More

Placing Many Graphics in a Document

Word documents can contain more than just text. You can even create documents that contain almost no text at all. This ...

Discover More

Left and Right Aligned on One Line in a Label

If you need to put information on a label that has both left- and right-aligned information on the same line, it can be ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (menu)

Setting the Left Indent of a Paragraph in a Macro

When using a macro to format text, you can set all sorts of attributes for paragraphs or individual characters. On ...

Discover More

Creating a Command List

Want a list of all the commands available in Word? You can get one easily by following these steps.

Discover More

Finding and Changing Word's Internal Commands

If you know how to create macros, you can easily create entire replacements for Word's internal commands. Here's all you ...

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 five minus 0?

2017-10-27 03:13:40


This is great for relative length but, it includes punctuation marks as mentioned below.
MS is aware of this and has an elegant workaround here:

2017-07-18 10:48:05


It worked fantastically, but how do I now get rid of the red text? Is there something I can add to the code to have it turn back to black text once I edit it to under 20 words? Thanks

2016-05-16 19:31:18

Peter Thomas

This may be useful. I have had trouble over the last couple of years getting documents to preview in Windows explorer. Searching on the Internet leads me to believe I'm one of many. Today I solved my problem and it may be useful to others: - This is for Word 2016

1. Open Windows Explorer.
2. Click to the View tab.
3. Click on Preview Pane.
4. Go to the right hand side and click Options.
5. Click on the selection that drops down.
6. In the Folder Options dialogue box click on View
7. Scroll down and click the check-box for "Show preview handlers in preview pane".
8. Click Apply and OK. The preview for will now show in the Preview Pane of Windows Explorer.

I hope this can be of value to you and your readers.


Peter Thomas

2015-04-22 08:13:47

Doug P

Just wanted to say thanks - this is great.

I'm an academic with a bad habit of writing long sentences and love the simplicity & flexibility of this.

Thanks for making and sharing this, you've made something that is useful. I hope you derive some satisfaction from knowing that!


2013-11-13 04:16:50



I am experiencing the same problem as beyondnerd. Is there a way to exclude puctuation marks from the sentence?

Please please help!

2013-04-24 16:47:23


I just noticed a problem. The value of MySent.Words.Count seems to include the number of words plus the number of punctuation marks (commas, quotation marks etc.).Consequently the following 19 word sentence (for example) is marked as having over 20 words.

After the yellow sun goes down, beyond the horizon, the quick brown fox jumps over the fat lazy dogs.

Is there a way to get the actual word (not including punctuation count)for each sentence? The word count function on the review tab gets the correct count.

2013-04-15 01:49:40


Very helpful, thank you

2013-03-03 10:38:36

José de la Riva

Hi, Allen. I´m having problems with this macro, because my Word 2007 doesn´t understand "'Set number of words". In Visual Basic, it´s highlighted in red, as other commands I´ve found in Jack Lyon´s Macro Cookbook. Is it due to my version of MS Word? Will it work in more recent versions of the program, like Word 2010? Thank you!

2012-11-23 05:58:41

Sam Hale

Really useful, thanks!

This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon 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.