views:

454

answers:

2

I have a VB6.0 project with MDI parent and child form. Now I need to check spelling and grammar in few text boxes on that child form.

Please help with code example.

+3  A: 

You could license a professional ActiveX component like Tachyon's spellchecker. I found a list here.

If you could demand Microsoft Word installed on the client machine as prerequisit, you could use Word's spell checker:

Dim objWord As Object
Dim objDoc  As Object

Dim strResult As String

' // Create a new instance of word Application

Set objWord = CreateObject("word.Application")

Select Case objWord.Version
   ' // Office 2000
   Case "9.0"
      Set objDoc = objWord.Documents.Add(, , 1, True)

   ' // Office XP
   Case "10.0"
      Set objDoc = objWord.Documents.Add(, , 1, True)

   ' // Office 97
   Case Else ' Office 97
      Set objDoc = objWord.Documents.Add

End Select

objDoc.Content = Text1.Text
objDoc.CheckSpelling

strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)

If Text1.Text = strResult Then
    ' // There were no spelling errors, so give the user a
    ' // visual signal that something happened

    MsgBox "The spelling check is complete.", vbInformation + vbOKOnly
End If

You can find another good example in this article about how to call the MS Word Spell Checker.

splattne
A: 

I want to call spell checker in c# please help

Umaid