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.


If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

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


Sudden Increases in Workbook File Size

Workbooks can get rather large rather quickly. If you think your workbook has gotten too big too fast, here are some ...

Discover More

Changing the Color of a Cell Border

Excel provides a variety of tools you can use to make your data look more presentable on the screen and on a printout. ...

Discover More

Searching by Columns, by Default

Do you often want to search through a worksheet by column rather than by row? Excel defaults to searching by row, of ...

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 (menu)

Editing Word's Built-in Commands

Want to configure Word to do just what you want it to? You can even go so far as to change the actual way in which Word ...

Discover More

Printing Summary Information from a Macro

Part of the information that Word maintains about each of your documents is a summary statement, which you can define in ...

Discover More

Occurrences of a Text String within a Document

You may have a need to find out how many times a certain text string occurs within a document. You can find out manually ...

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.