VB中調用Word拼寫檢查
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 |