您现在的位置: Office学院 - Word - VB 中调用 Word 拼写检查

VB 中调用 Word 拼写检查

添加记录:  类别: Word 发布日期: 2006.09.22

  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

Tags: word 文件