In some applications, user may need to invoke a spell checker to check spelling for the text entered. We can invoke MS word's spell checker by writing few lines of code.
Open a new project, draw a text box and a command button in the form. Add MS word object library in references. Then write the following code in the command button's click event.
Public Sub
Command1_Click()
'Create an instance of word application
Dim wb As New Word.Application
Dim oNewdoc As Object
'Add one new document object
Set oNewdoc = wb.Documents.Add
'Insert the text entered in the Text box to the document
wb.Selection.TypeText Text1.Text
'Invoke the Spell checker
retStr = oNewdoc.CheckSpelling()
'Select the corrected text in the document
wb.Selection.WholeStory
'Copy the selected text to Clipboard
wb.Selection.Copy
'Paste the text to the text box
Text1.Text = Clipboard.GetText
'Close the newly added document object without saving
oNewdoc.Close False
wb.Quit
Set oNewdoc = Nothing
Set wb = Nothing
Me.SetFocus
End Sub
After entering
the code, run the project and enter some text in the text box. Then click
the command button to invoke the spell checker.