As we all know, Word has its own spell check function. In VB, it is actually very simple to call the Word spell check function. The method is to first create a word object, then put the string that needs to be checked into WORD, call the word spell check, then take out the return value, and finally close the object.
The specific implementation code of each step is as follows:
Function CheckSpell(IncorrectText as string) as stringDim Word As Object, retText$ On Error Resume Next 'Create a WORD object and open Set Word = CreateObject("Word.Basic")'Put the STRING that needs to be checked into WORDWord.AppShowWord.FileNewWord. Insert IncorrectText'Call WORD spelling checkWord.ToolsSpellingWord.EditSelectAll'get the return value retText = Word.Selection$()CheckSpell = Left$(retText, Len(retText) - 1)'Close the fileWord.FileClose 2 ShowSet Word = NothingEnd FunctionThis example is provided with detailed comments to help readers understand. In addition, readers can refer to other materials based on this example to make further improvements to achieve more powerful functions!