February 27, 2021
Hot Topics:

Make a Spell Checker

  • By Sam Huggill
  • Send Email »
  • More Articles »

Spell checking has always been one of MS Word's greatest features, but now you to can include spell checking into your application with out increasing your file size.

This great example demonstrates how you can setup a spell check by opening Word, copying and pasting the text, spell check it and then close down Word.

Private Function FN_SpellCheck(strTextToVerify As String) _
  As Boolean
On Error GoTo FN_SpellCheckErr

Dim oWord As Object
Dim strSelection As String
Set oWord = CreateObject("Word.Basic")
With oWord
  ' done immediately before to minimize possibility of
  ' user interaction with the clipboard
  Clipboard.SetText strTextToVerify, vbCFRTF
  On Error Resume Next
  On Error GoTo 0
  strSelection = Clipboard.GetText(vbCFRTF)
  If Mid(strSelection, Len(strSelection), 1) = Chr(13) Then
    strSelection = Mid(strSelection, 1, Len(strSelection) - 1)
  End If

  If Len(strSelection) > 1 Then
    strTextToVerify = strSelection
    FN_SpellCheck = True
  End If
  .FileCloseAll 2
End With

Set oWord = Nothing

Exit Function

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date