As we all know, Word has its own spell checking feature. VB to implement the call Word spell check function is very simple to achieve, the way is to create Word objects, and then put the need to check the string into Word, call the word spell check, then remove the return value, and finally close the object.
The specific implementation code for each step is shown below:
Function Checkspell (Incorrecttext As String) As String
Dim Word as Object, rettext$ on
Error Resume Next
' Build wo Rd object and open
Set Word = CreateObject ("Word.Basic")
' put the STRING you want to check into Word
word.appshow
word.filenew
Word.Insert incorrecttext
' calls Word spelling checker
word.toolsspelling
word.editselectall
' gets the return value
Rettext = word.selection$ ()
Checkspell = left$ (Rettext, Len (Rettext)-1)
' closes file
word.fileclose 2
Show
Set Word = no end
Function
This example has detailed comments to help readers understand, in addition to the reader can also be based on this example to see other materials for further improvement to achieve more powerful features!