VB中调用Word拼写检查
【打印文章】
Function CheckSpell(IncorrectText as string) as string
Dim Word As Object, retText$
On Error Resume Next
‘ 建立对象并打开 WORD
Set Word = CreateObject("Word.Basic")
‘ 把需要检查的 STRING 放到 WORD
Word.AppShow
Word.FileNew
Word.Insert IncorrectText
‘ 运行 WORD 拼写检查
Word.ToolsSpelling
Word.EditSelectAll
‘ 取返回值
retText = Word.Selection$()
CheckSpell = Left$(retText, Len(retText) - 1)
‘关闭文件并回到 VB 应用
Word.FileClose 2
Show
Set Word = Nothing
End Function
Dim Word As Object, retText$
On Error Resume Next
‘ 建立对象并打开 WORD
Set Word = CreateObject("Word.Basic")
‘ 把需要检查的 STRING 放到 WORD
Word.AppShow
Word.FileNew
Word.Insert IncorrectText
‘ 运行 WORD 拼写检查
Word.ToolsSpelling
Word.EditSelectAll
‘ 取返回值
retText = Word.Selection$()
CheckSpell = Left$(retText, Len(retText) - 1)
‘关闭文件并回到 VB 应用
Word.FileClose 2
Show
Set Word = Nothing
End Function
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )
【编程爱好者论坛】