VB中调用Word拼写检查
FunctionCheckSpell(IncorrectTextasstring)asstring
DimWordAsObject,retText$
OnErrorResumeNext
'建立对象并打开WORD
SetWord=CreateObject("Word.Basic")
'把需要检查的STRING放到WORD
Word.AppShow
Word.FileNew
Word.InsertIncorrectText
'运行WORD拼写检查
Word.ToolsSpelling
Word.EditSelectAll
'取返回值
retText=Word.Selection$()
CheckSpell=Left$(retText,Len(retText)-1)
'关闭文件并回到VB应用
Word.FileClose2
Show
SetWord=Nothing
EndFunction->
DimWordAsObject,retText$
OnErrorResumeNext
'建立对象并打开WORD
SetWord=CreateObject("Word.Basic")
'把需要检查的STRING放到WORD
Word.AppShow
Word.FileNew
Word.InsertIncorrectText
'运行WORD拼写检查
Word.ToolsSpelling
Word.EditSelectAll
'取返回值
retText=Word.Selection$()
CheckSpell=Left$(retText,Len(retText)-1)
'关闭文件并回到VB应用
Word.FileClose2
Show
SetWord=Nothing
EndFunction->
- 上一篇:在Word中嵌入应用程序
- 下一篇:在VB中控制Word
精彩图集
精彩文章