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


Changing the Way Endnotes Are Numbered

Word is flexible on how it numbers your endnotes. This tip shows how easy it is to make the changes to the numbering system.

Discover More

Inserting the Current Month

Need to add the name of the current month to your document? Word includes a field that can make the addition easy, and it ...

Discover More

Inserting a Cross-Reference to the Last Style on a Page

It is often helpful to reference a specific heading in the header or footer of a page, and have that reference change on each ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (menu)

Adding a Macro to a Toolbar

One of the easiest ways to quickly access a macro is to assign it to a toolbar button. How you make the assignment depends on ...

Discover More

Word's Object Model

Understanding Word's Object Model and how it relates to macros in VBA.

Discover More

Calculating a Future Date

Need to figure out a date a certain number of days, weeks, months, or years in the future? It's easy to do using the DateAdd ...

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 nine minus 3?

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.