Spell Checking

Glowman used Ask the Experts™
Hi there,
I am trying to create an app that utilizes Word's spell check functionality, but I am having a hard time figuring out what to do when the CheckSpelling() method comes back with a false value.  I will award the points to anyone who can show  me an example.  BTW I base my assumptions on using the Word Object and I instatiate it like so:
Public WordTool As New Word.Document
with a reference in the project to "Microsoft Word 8.0 Object libraray"
Thanks in advance
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Set SpellErrors = SC.GetSpellingSuggestions(Word:=txtSpell.Text)

  If SpellErrors.Count > 0 Then
    For Each SpellError In SpellErrors
      lstCorrect.AddItem SpellError.Name
    Next SpellError
  ElseIf SC.CheckSpelling(Word:=txtSpell.Text) Then
    lstCorrect.AddItem txtSpell.Text
  End If

Here's a good place with sample source code:  


If you want to do it without using word, try:

simpler code here:



Excellent so far,
Just one more thing and you can have the points.
How can I get it to give me only the top option and not a list of all choices?
I'm not positive, but I think the first item in the list after a call to GetSpellingSuggestions is the best suggestion and it goes downhill from there.  That seems to be the way Word produces them.


ok, fair enough,
Thanks for the prompt response.
You could test for the first item that meets the SpellingErrorType  condition if you are concerned that you might receive Capitalization errors before "Not in Dictionary" errors like:

If suggs.SpellingErrorType = wdSpellingNotInDictionary Then
    StatusBar = "Unknown word"
End If

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial