top of page

Find keywords quickly by getting a list of spelling errors

If you want help getting a list of last names or other proper nouns which may be keywords in a long text excerpt, you can make use of the below Visual Basic macro which will generate a list of words that MS Word will identify as possible spelling errors.

If you simply plug in the code in a new module in Visual Basic:

. . . the macro will review a Word document:

. . . and output a list of the words which are not in the spell check dictionary:

Thanks to Jay Freedman for posting this macro here. [Copy the text from the post on the Microsoft site, or remove the extra blank lines that result when you paste this code into Visual Basic to make it work.]

Sub ListSpellingErrors()

Dim inDoc As Document

Dim outDoc As Document

Dim er As Range

Set inDoc = ActiveDocument

If ActiveDocument.SpellingErrors.Count > 0 Then

Set outDoc = Documents.Add

outDoc.Sections(1).Headers(wdHeaderFooterPrimary) _

.Range.Text = "Spelling errors in " & inDoc.FullName


MsgBox "There are no spelling errors in this document."

Exit Sub

End If

For Each er In inDoc.SpellingErrors

outDoc.Range.InsertAfter er.Text & vbCr

Next er

' optionally, to sort the output,

' remove the quote mark from the next line

' outDoc.Range.Sort

End Sub


bottom of page