Displaying Sentence Word Counts in Word 2007

Microsoft Word, Tips & Tricks Add comments

mswordtweak.pngWhen you grammar check a document, you can elect to display the document’s readability statistics. (Select Office, Word Options, click Proofing, and activate the Show Readability Statistics check box.) Among other values, the Readability Statistics dialog box offers the average number of words per sentence. This is useful because you don’t want your average sentence to be too long or too short. However, writing gurus also stress that you should have a variety of sentence lengths in your prose, with some shorter and longer sentences thrown in for reading variety. Unfortunately, the Readability Statistics dialog box doesn’t tell you the lengths of your sentences, but it’s easy enough to get a VBA macro to do it for you, as shown in Listing 1.

Listing 1 A Macro That Displays the Lengths of Sentences in the Active Document

A Macro That Displays the Lengths of Sentences in the Active Document

Using the ActiveDocument object, the macro makes a first pass through all the sentences to find the one with the most words. The macro then uses this maximum word count to redi­mension the sentenceLengths array, which is used to hold the number of occurrences of each sentence length within the document. To calculate these frequencies, the macro then runs through all the sentences again and increments the array values for each length. The macro finishes by constructing and then displaying a string that holds the sentence lengths and frequencies. Figure 1 shows an example.

The Display-SentenceLengths macro displays a mes­sage box such as this to show you the document’s sentence lengths and the frequency with which each length occurs
Figure 1 The Display-SentenceLengths macro displays a mes­sage box such as this to show you the document’s sentence lengths and the frequency with which each length occurs.

TIP

If you’re also interested in displaying data for each paragraph, replace .Sentencesin Listing 1.1 with .Paragraphs. Because the variable sis a Rangeobject, you can work with either the words in each paragraph-s.Words.Count-or the sentences in each paragraph-s.Sentences.Count.

Technorati Tags:

Popularity: 2% [?]

Related Post

  • Finding the Longest Sentence in a Document in word 2007
  • Using AutoCorrect to Enter Boilerplate Text in MS Word 2007
  • Converting Uppercase Words to Another Case in Word 2007
  • Automatically Prompting for Document Properties in Word 2007
  • Showing More Items on the Recent Documents List in Word 2007
  • Don't Find What You're Looking For? Please Try Here...

    Google
     

    Leave a Reply

    WP Theme & Icons by N.Design Studio
    Entries RSS Comments RSS Add to Technorati Favorites Log in