How To Use Microsoft Office Word Spell Checker In Your Project In VB.NET

How To Use Microsoft Office Word Spell Checker In Your Project In VB.NET
Last night i was thinking on how to do this (title) then i came with an idea , i did a program that converts Docx(Microsoft Office Document) to DOC(Microsoft Office Word 98-2003 Document) so i used the same method but had to tweak . for this you don't need to have any classes or dll's i have created two functions that will do the work , to make this first you need a button and a textbox then double click the form and add these code(s).



Public Class Form1
    'Author : Mohamed Shimran
    'Blog : http://www.ultimateprogrammingtutorials.blogspot.com

    Private Function Check_(ByVal Text As String) As Boolean
        Dim Spelling_checker As New Object()
        Spelling_checker = CreateObject("Word.Application")
        Check_ = Spelling_checker.CheckSpelling(Text)
    End Function
    Public Function OnlyCharacter(ByVal key As String) As Boolean
        If (key >= 65 And key <= 90) Or (key >= 97 And key <= 122) Or key = 8 Then
            OnlyCharacter = False
        Else
            OnlyCharacter = True
            MsgBox("enter only characters")
        End If
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Shim As String
        On Error Resume Next
        Shim = TextBox1.Text

        If Check_(Shim) = True Then
            MsgBox("The Spelling Is Correct.", vbInformation, "Spell check")
        Else
            MsgBox("The Spelling Is Wrong.", vbCritical, "Spell check")
        End If
        Shim = ""
    End Sub
End Class

when you run this program try entering correct words and wrong words in the textbox and click on the button and see whether it works or not . if the word is correct you will get a messagebox with The Spelling Is Correct if it's wrong you will get a messagebox with The Spelling Is Wrong , i think you can simply integrate this to your project/programs . i hope it helped you .

1 comments:

Post a Comment

Note: Only a member of this blog may post a comment.