Spell Checker in a Visual Basic Program

Hello all,

l want to known if it is possible to have a spell checker in a vb application, if so, has anyone got some code l could use or give me directions on where l could find some.

lm using VB 5.

regards Ashtray
Who is Participating?
twardConnect With a Mentor Commented:
Here is some code that I know works to spell check using word:

Public Sub SpellCheck()
Dim oWDBasic As Object
Dim FileName As String

' Open Word '  
Set oWDBasic = CreateObject("Word.Basic")

' Load Text File into Rich Text Box '    
RichText1.LoadFile FileName, rtfText

' Load File into Word '
oWDBasic.Insert RichText1.Text
' Spell Check the File '

' Get text back into Rich Text Box '
oWDBasic.SetDocumentVar "MyVar", oWDBasic.Selection

sTmpString = oWDBasic.GetDocumentVar("MyVar")

sTmpString = Replace(Left(sTmpString, Len(sTmpString) - 1), vbCr, vbCrLf, 1, -1, vbTextCompare)

' Only Save it if it has changed '
If RichText1.Text <> sTmpString Then
  RichText1.Text = sTmpString
  RichText1.SaveFile FileName, rtfText
End If

' Close File in Word '    
oWDBasic.FileClose 2

' Close Word '    
oWDBasic.FileQuit 2
Set oWDBasic = Nothing
End Sub
5 / 8
There is a method that uses MS Words spellcheck function that can be integrated into a VB app, if that will fit you needs.  However, this requires that MS Word be installed on the target PC in order for spell check to work in your program.
7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

This microsoft URL whows you how to spellcheck...

HOWTO: Use the Word 6.0 SpellChecker Via OLE Automation in Visual Basic

By the way, in the example microsoft gave, there's something missing...
After the line:

        MsgBox "Spell Check is complete"

Add the following:

        oWDBasic.FileClose 2
        Set oWDBasic = Nothing

That will close word.
Ashtray: Where are you? Please say something so we could be of any help to you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.