Account Login  Username:  Password: 

Automation of the Word Spell Checker

by John Edward Colman
Category: Microsoft Office Apps/VBA
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3 February 2021
Rating: (5 Votes)

To help out my Dutch friend Frederik who needed to spell check in various languages, I designed this simple example.
To adapt it to use a particular dictionary, supply the dictionary path as an option like so:

Works better if you type one word at a time. Of course, you'll write you code to automate this.
You'll need to own a fairly recent copy of Word. I used Word 97.
Code Returns
Tells you if the spelling is good or a list of suggestions if not.
Side Effects
Lot's of votes I hope!
API Declarations
No Windows API.
Create a form with a TextBox CommandButton and ListBox.
Also include the Word library by selecting these menu options:
Project > References:
and checking "Microsoft Word 8.0 Object Library".

Rate Automation of the Word Spell Checker

Option Explicit
'Create a reference to the Word Automation Object
Dim w1 As Word.Application
Private Sub Command1_Click()
  Dim I As Variant
  'Empty the list box
  'Check the spelling of the word...
  'If not in dictionary, fill a list box with suggestions
  If w1.CheckSpelling(Text1.Text) = False Then
    For Each I In w1.GetSpellingSuggestions(Text1.Text)
      List1.AddItem I
    If List1.ListCount = 0 Then
      List1.AddItem "No suggestions"
    End If
    List1.AddItem "Spelling Correct"
  End If
End Sub
Private Sub Form_Load()
  'Open a new instance of Word
  Set w1 = New Word.Application
  'Create a new document (necessary)
  'Disable the following line if you don't want to see Word
  w1.Visible = True
End Sub
Private Sub Form_Terminate()
  'Quit, ignoring changes
  w1.Quit False
  Set w1 = Nothing
End Sub

Download Snippet Download this snippet   Add to My Save List Add to My Saved Code

Automation of the Word Spell Checker Comments

No comments have been posted about Automation of the Word Spell Checker. Why not be the first to post a comment about Automation of the Word Spell Checker.

Post your comment


0/1000 characters