July 24, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Make a Spell Checker

  • November 19, 2002
  • 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
  .AppMinimize
  .FileNewDefault
  .EditSelectAll
  ' done immediately before to minimize possibility of
  ' user interaction with the clipboard
  Clipboard.SetText strTextToVerify, vbCFRTF
  .EditPaste
  .StartOfDocument
  On Error Resume Next
  .ToolsSpelling
  On Error GoTo 0
  .EditSelectAll
  .EditCOPY
  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
  .AppClose
End With

Set oWord = Nothing

Exit Function





Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel