Include MS Word Spell Checker to check spellings in project using Visual Basic

add one text box and button to the form. When you click the button add the following code.

Private Sub Command1_Click()


    Dim objWord

    Dim new_objword

    Dim results


    'if the text is not empty then only continues .

    If Len(Text1.Text) < 1 Then Exit Sub

    'from the references include the Microsoft word 9.0 Object library


   Set new_objword = CreateObject("Word.Application")

   'check if there are any spelling errors.

   If new_objword.CheckSpelling(Text1.Text) Then

      MsgBox "This word  spelled correctly"

      ' free memory

      Set new_objword = Nothing

    Exit Sub

   End If


   'free memory

   Set new_objword = Nothing

   Set objWord = CreateObject("Word.Application")

   With objWord

      ' hide the Word application

      .Visible = False

      ' Spell checker only works within a document


      ' Put the text in the document

      .Selection.TypeText Text1.Text


      ' disallow grammer checking. To allow it set it to "True"

      .Options.CheckGrammarWithSpelling = False

      .Options.IgnoreUppercase = False


      ' Perform the spell checking



      ' results holds the text after the spell corrections


      results = .Selection.Text


      ' close and free memory

      .ActiveDocument.Close (0)


   End With


   Set objWord = Nothing

      ' retrieve the corrected text from the clipboard

      Text1.Text = Clipboard.GetText


End Sub

Added on September 8, 2008 Comment