HOWTO: VB3: Use the Word SpellChecker Via OLE Automation |
Q114020
This article shows by example how to use the built-in SpellChecker from
Microsoft Word version 6.0 to check the spelling of the contents of a
text box in a Microsoft Visual Basic version 3.0 application.
The example takes the contents of a Visual Basic text box, inserts the
text into a Word document, and then spell checks the text. After the spell
check is complete, you insert the spell checked text from the Word document
back into the Visual Basic text box.
Sub Form_Load()
Command1.Caption = "Press to SpellCheck"
Text1.Text = "The Seattle SuperSonics ar goig all the wa _
this yeer!!"
End Sub
Sub Command1_Click ()
Dim oWDBasic As Object
Dim sTmpString As String
Set oWDBasic = CreateObject("Word.Basic")
oWDBasic.FileNew
oWDBasic.Insert Text1.Text
On Error Resume Next
oWDBasic.ToolsSpelling
oWDBasic.EditSelectAll
oWDBasic.SetDocumentVar "MyVar", oWDBasic.Selection
sTmpString = oWDBasic.GetDocumentVar("MyVar")
Text1.Text = Left(sTmpString, Len(sTmpString) - 1
MsgBox "Spell Check is complete"
End Sub
SuperSonics(Ignore)
ar(Change to are)
goig(Change to going)
wa(Change to way)
yeer(Change to year)
After the last correction, you will get a Message box telling you that
the Spell Check is complete. The results inserted back into the Text1
text box should say this:
The Seattle SuperSonics are going all the way this year!!
Additional query words:
Keywords : kbprogramming kbVBp300
Issue type : kbhowto
Technology : kbWordSearch kbVBSearch kbAudDeveloper kbZNotKeyword2 kbVB300Search kbVB300 kbWord600
|
Last Reviewed: May 5, 2001 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |