If you need to frequently refer to readability statistics in Microsoft Word, but you dread running through spell check unnecessarily, these macros are for you!
Many of us depend on readability statistics to improve our writing or to write to a specific audience in Microsoft Word. If the feature is enabled, you'll see a list of statistics after running spell check. Unfortunately, running spell check is the only time you'll see those statistics, which can be tedious especially if the document is large and complex. If you cancel the spell check, you won't see the statistics. In this article, I'll show you a few VBA procedures that will display statistics in three different ways.
SEE: 69 Excel tips every user should master (TechRepublic)
I'm using Microsoft 365 on a Windows 10 64-bit system, but you can use earlier versions. The online version doesn't support macros. You can download the demonstration .docx, .doc and .cls files or use the =RAND() function to create a few paragraphs of text and enter the code yourself. This article assumes you have basic Word skills, but even a beginner should be able to work through this article with success.
How to enable readability statistics in Microsoft Word
If you don't see readability statistics after running spell check, the feature isn't enabled. To enable it, do the following:
- Click the File tab and choose Options (or More if Options isn't visible).
- Choose Proofing in the left pane.
- In the When Correcting Spelling and Grammar in Word section, check the Show Readability Statistics option, as shown in Figure A.
How to enter and run code in Word
To enter code, press Alt + F11 to open the Visual Basic Monitor. In the Project Explorer to the left, choose ThisWorkbook and enter the code. Or import the downloadable .cls file. Don't paste code directly from this web page. Instead, you can copy it to any text editor and then copy the text from the text editor into a module. If you're using a ribbon version, you must save the file as a macro-enabled file to use macros.
When in the VBE, you can press F5 to run a procedure, but be sure to click inside the procedure you want to run. When in a Word document, click the Developer tab, click Macros in the Code group, choose the procedure in the resulting dialog shown in Figure B, and then click Run.
How to display the readability statistics one by one
The only way to trigger Word's readability statistics via the interface is to run a spell check (F7). If your document is long, you can waste a bit of time trying to work through the document. If you cancel the spell check, Word returns you to the document immediately, without displaying the statistics.
The short procedure in Listing A will display all the statistics, one by one. It's a bit tedious if you only want to view one of them, but you can run this outside of a spell check task.
'Cycle through the readability statistics and display one by one in a message box.
For Each rs In Selection.Range.ReadabilityStatistics
MsgBox rs.Name & " - " & rs.Value
Run the macro, and you'll see a message box similar to the one in Figure C. You must press OK to view the next statistic—there are several of them.
The For Each loop cycles through the ReadabilityStatistics collection. The message box displays the concatenated Name and Value properties in the following order: Words, Characters, Paragraphs, Sentences, Sentences per Paragraph, Words per Sentence, Characters per Word, Passive Sentences, Flesch Reading Ease, Flesch-Kincaid Grade Level and Passive Sentences. You can't change the order in this simple procedure. To view specific statistics, add a check for that object.
How to display the readability statistics one at a time
Cycling through all of the statistics one by one is OK, but perhaps you want to see only one statistic. In this case, you can specify that statistic object as shown in Listing B. This procedure displays only one statistic, the Flesch-Kincaid Grade Level, whose index value is 9. (More about that in a minute.) Figure D shows the result of running this procedure.
'Display grade level.
Set rsRange = ActiveDocument.Content
rs = rsRange.ReadabilityStatistics(9).Value
MsgBox "Grade Level: " & rs
You might have noticed that this procedure uses the index value 9 to retrieve the grade-level statistic. Remember the order I mentioned, and that you can't change it? That's where the index values come in. See Table A for a complete list. Use index values to display specific statistic values.
Sentences per Paragraph
Words per Sentence
Characters per Word
Flesch Reading Ease
Flesch-Kincaid Grade Level
So far, we've seen two procedures that return readability statistics: one displays them all one at a time, and one displays only one. Let's look at a procedure that displays them all at the same time.
How to display the readability statistics all at once
It's likely that you'll want to see all of the statistics in one efficient screen. Listing C does this. It's basically the same as Listing A, but this time, the code creates a long string that contains all of the statistics and displays that string in one message box screen, as shown in Figure E.
'Display all readability statistics on one screen.
Dim strStats As String
'Reset string to nothing.
strStats = ""
'Cycle through statistics and build string.
For Each rs In Selection.Range.ReadabilityStatistics
strStats = strStats & rs.Name & ": " & rs.Value
strStats = strStats & vbCrLf
'Display all stats.
MsgBox strStats, vbOKOnly, "Readability Statistics"
You can display them all at once!
As is, none of the procedures contain any error handling, so you might want to drop in some code to cover potential errors. If you use these statistics, outside of spell check, often, you might want to add a custom group to the ribbon and add the appropriate statistic-displaying macros there.
- How to make fewer mistakes and work more efficiently using predictive text in Microsoft 365 (TechRepublic)
- How to use the many text wrapping options in Microsoft Word (TechRepublic)
- Microsoft 365: A cheat sheet (TechRepublic)
- Zoom vs. Microsoft Teams, Google Meet, Cisco WebEx and Skype: Choosing the right video-conferencing apps for you (free PDF) (TechRepublic)
- Checklist: Securing Windows 10 systems (TechRepublic Premium)
- Everything you need to know about the Microsoft Exchange Server hack (ZDNet)
- Must-read coverage: Windows 10 (TechRepublic on Flipboard)