Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
i have to use a textbox which will do spell check of the words entered inside it ,pls help
Posted

hi.

try.

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

    'Clean up
    objDoc.Close False
    Set objDoc = Nothing
    objWord.Application.Quit True
    Set objWord = Nothing

    ' Replace the selected text with the corrected text. It's important that
    ' this be done after the "Clean Up" because otherwise there are problems
    ' with the screen not repainting
    Text1.Text = strResult

    Exit Sub




pm me if its not working.
i'll try to answer back.


hope it helps.
goodluck. :)


-chaosgray-
 
Share this answer
 
Comments
version_2.0 8-Jun-11 2:05am    
need this in C#...
plz convert this to C#...
chaosgray 8-Jun-11 2:12am    
get my code and go to this link.

http://www.developerfusion.com/tools/convert/vb-to-csharp/


it is a code converter.

-chaosgray-
Hello,
I think it needs 2 matters:
1. A dictionary contains many words that the programme must compare each word of it's TextBox.
2. If you want a strong spell checker then you have to work on the grammer for example:
I work hard.
She works hard. (s)
may I work hard? (?)
 
Share this answer
 
 
Share this answer
 
Comments
sharathu7 8-Jun-11 0:44am    
thanks it helped me too
You will need to use a third party to implement this.
Unless you can integrate with word somehow.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900