Microsoft Word Readability Statistic VBA (Visual Basic for Applications)

Microsoft Word Readability Statistic VBA (Visual Basic for Applications)

ReadabilityStatistics

Represents one of the readability statistics for a document or range. ReadabilityStatistics collection can be iterated using an index (a positive integer) by which ReadabilityStatic object can be referenced.

Properties

  1. Words
  2. Characters
  3. Paragraphs
  4. Sentences
  5. Sentences per Paragraph
  6. Words per Sentence
  7. Characters per Word
  8. Flesch Reading Ease
  9. Flesch-Kincaid Grade Level
  10. Passive Sentences

Code example

Public Sub ReadabilityStatisticCodeExample()
    'Declare object to hold a document
    Dim oDocument As Document
    
    'Reference active document
    Set oDocument = ActiveDocument
    
    'Print Words in document
    Debug.Print "Words in Document: " & oDocument.Content.ReadabilityStatistics(1).Value
    
    'Print Characters in document
    Debug.Print "Characters in Document: " & oDocument.Content.ReadabilityStatistics(2).Value
    
    'Print Paragraphs in document
    Debug.Print "Paragraphs in Document: " & oDocument.Content.ReadabilityStatistics(3).Value
    
    'Print Sentences in document
    Debug.Print "Sentences in Document: " & oDocument.Content.ReadabilityStatistics(4).Value
    
    'Print Sentences per Paragraph in document
    Debug.Print "Sentences per Paragraph in Document: " & oDocument.Content.ReadabilityStatistics(5).Value
    
    'Print Words per Sentence in document
    Debug.Print "Words per Sentence in Document: " & oDocument.Content.ReadabilityStatistics(6).Value
    
    'Print Characters per Word in document
    Debug.Print "Characters per Word in Document: " & oDocument.Content.ReadabilityStatistics(7).Value
    
    'Print Flesch Reading Ease in document
    Debug.Print "Flesch Reading Ease in Document: " & oDocument.Content.ReadabilityStatistics(8).Value
    
    'Print Flesch-Kincaid Grade Level in document
    Debug.Print "Flesch-Kincaid Grade Level in Document: " & oDocument.Content.ReadabilityStatistics(9).Value
    
    'Print Passive Sentences in document
    Debug.Print "Passive Sentences in Document: " & oDocument.Content.ReadabilityStatistics(10).Value
    
    'Memory cleanup
    Set oDocument = Nothing
End Sub

Output

Words in Document: 24
Characters in Document: 107
Paragraphs in Document: 17
Sentences in Document: 1
Sentences per Paragraph in Document: 1
Words per Sentence in Document: 5
Characters per Word in Document: 4.6
Flesch Reading Ease in Document: 49.4
Flesch-Kincaid Grade Level in Document: 7.6
Passive Sentences in Document: -0.11

Please leave your comments or queries under comment section also please do subscribe to out blogs to keep your self upto date.

Leave a Reply

Your email address will not be published.