QTP 自带了一个spellcheck 的VBS,如何用它实现对web page的拼写检查呢?

来源:百度知道 编辑:UC知道 时间:2024/05/28 09:46:59
请高手结合这个脚本,讲解以下。

Function NumberOfSpellErrors(strText)
Dim objMsWord
Set objMsWord = CreateObject("Word.Application")
objMsWord.WordBasic.FileNew
objMsWord.WordBasic.Insert strText
NumberOfSpellErrors = objMsWord.ActiveDocument.SpellingErrors.Count
objMsWord.Documents.Close (False)
objMsWord.Quit ' close the application
Set objMsWord = Nothing' Clear object memory
End Function

' The following function uses the Spell errors function to check a specific property
' of all the objects with a given description which are under a given Parent

Sub CheckAllObjects(ParentObj, ObjDesc, PropName)
Dim ObjCol, idx, PropValue, OldReportMode
OldReportMode = Reporter.Filter
Reporter.Filter = 2 ' report only errors
If (IsNull(ParentObj)) Then
Set ObjCol = Desktop.ChildObjects(ObjDesc)
Else
Set ObjCol = Paren

语法检查使用的是word的语法检查功能,
此脚本运行的前提条件就是安装word。

Function NumberOfSpellErrors(strText)
Dim objMsWord
'创建word
Set objMsWord = CreateObject("Word.Application")
'定义一个新的word文档
objMsWord.WordBasic.FileNew
'文档中插入要检查的文本
objMsWord.WordBasic.Insert strText
’语法错误的个数
NumberOfSpellErrors = objMsWord.ActiveDocument.SpellingErrors.Count
'关闭新建的word文档 不保存
objMsWord.Documents.Close (False)
’推出wordobjMsWord.Quit
' close the application
Set objMsWord = Nothing' Clear object memory
End Function

' The following function uses the Spell errors function to check a specific property
' of all the objects with a given description which are under a given Parent

Sub CheckAllObjects(ParentObj, ObjDesc, PropName)
Dim ObjCol, idx, PropValue, OldReportMode
OldReportMode = Reporter.Filter
'只在report中显示错误的操作
Reporter.Filter = 2 &