Spell chcek textbox text

I have a textbox in a Data Project in VB. The textbox is not data bound. I just want to run a spell check on the text(as simply as possible.) Anyone know how to do this?
LVL 1
jamaussAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KhollADCommented:
The trick below uses the Spell check of the MS Word in VB :

Dim Word As Object, retText$

    Text1.Text = SpellCheck(Text1.Text)
    Word.appClose
    Set Word = Nothing
Private Sub Command1_Click()

     
End Sub

Private Function SpellCheck(ByVal CheckText As String) As String

On Local Error Resume Next

Set Word = CreateObject("Word.Basic")

Word.FileNew
Word.Insert CheckText

Word.ToolsSpelling
Word.EditSelectAll

retText = Word.Selection$()
SpellCheck = Left$(retText, Len(retText) - 1)

Word.FileClose 2
Show

End Function
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KhollADCommented:
oops. Correct Command1_Click :

Private Sub Command1_Click()

Dim Word As Object, retText$

    Text1.Text = SpellCheck(Text1.Text)
    Word.appClose
    Set Word = Nothing
     
End Sub
0
jamaussAuthor Commented:
KhollAD,
  I tried this and i wanted to know how to close the WORD app by default. I know you gave me the code to do so but I can't use the SHOW in your code at the end of the function because the form the textbox is on has to be displayed modally and when the Word.appclose code executes it gives me error : object variable or with block variable not set. Is there some generic variable I haven't replaced with my own in the code? Everything works BUT closing the WORD app after completion of spell check. Could you help?

Jason
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

jamaussAuthor Commented:
Is there a reference I need in my project or anything like that?

Jason
0
KhollADCommented:
Hi Jason,

 Sorry about the delayed comment, when I correct the answer in last comment, I placed the declaration of 'Word' variable in Command1 sub, must be in top-level form declaration.

 Test the new code below, any doubts or problems send a comment.

Kholl.


Dim Word As Object, retText$

Private Sub Command1_Click()

    Text1.Text = SpellCheck(Text1.Text)
    Word.appClose
    Set Word = Nothing

End Sub

Private Function SpellCheck(ByVal CheckText As String) As String

On Local Error Resume Next

Set Word = CreateObject("Word.Basic")

Word.FileNew
Word.Insert CheckText

Word.ToolsSpelling
Word.EditSelectAll

retText = Word.Selection$()
SpellCheck = Left$(retText, Len(retText) - 1)

Word.FileClose 2


End Function


0
jamaussAuthor Commented:
YOu forgot the code Word.FileExit so I had to figure that out on my own but very good help on everything else. THanks!
0
KhollADCommented:
Yes, you can use Word.FileExit. I really never use this, is a good implemmentation.

Thanks, for the points and the comment.

See u Later.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.