Active Topics Memberlist Calendar Search Help | |
Register Login |
One Stop Testing Forum : Testing Tools @ OneStopTesting : QuickTest Pro @ OneStopTesting |
Topic: QTP and Word Spell Checker |
|
Author | Message |
Mithi25
Senior Member Joined: 23Jun2009 Online Status: Offline Posts: 288 |
Topic: QTP and Word Spell Checker Posted: 27Oct2009 at 11:55pm |
The following code shows a function for checking the number of spelling and grammar errors in a string.
Using Microsoft Word Spell CheckThe following code shows a function for checking the number of spelling and grammar errors in a string.
Function NumberOfSpellErrors(strText)
Set objMsWord = CreateObject("Word.Application")
objMsWord.WordBasic.Insert strText
NumberOfSpellErrors = objMsWord.ActiveDocument.SpellingErrors.Count
objMsWord.Documents.Close (False)
objMsWord.Quit ' close the application
Set objMsWord = Nothing' Clear object memory
' 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
Set ObjCol = Desktop.ChildObjects(ObjDesc)
Set ObjCol = ParentObj.ChildObjects(ObjDesc)
PropValue = ObjCol.Item(idx).GetROProperty(PropName)
RetVal = NumberOfSpellErrors(PropValue) ' The actual spell check result
ReportText = "Object #" & idx+1 & ": The '"
& PropName & "' Property has " & RetVal & " spell
errors (" & PropValue & ")"
Reporter.ReportEvent 1, "Spell Check", ReportText
Reporter.Filter = OldReportMode
'''''''''''''''''''''''''''''''''''''
' Go over all the static objects in the Login window of the Flight Application
' and for each object check the text for spelling and grammatical errors
'''''''''''''''''''''''''''''''''''''
' Go over all the links in the page and report all the ones that fail the spellcheck
Set Desc = Description.Create()
Desc("nativeclass").Value = "Static"
Set Obj = Dialog("nativeclass:=#32770", "text:=Login")
' Invoke the Flight Application before calling the function
|
|
Post Resume: Click here to Upload your Resume & Apply for Jobs |
|
IP Logged | |
Forum Jump |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
© Vyom Technosoft Pvt. Ltd. All Rights Reserved.