This is the cause for the error you get:
For i= 2 To rowct
strText = objFrame.WebTable("WebTable").GetCellData(i,1)
index = i-2
If Instr(strText,strType) > 0 Then
objFrame.WebTable("WebTable").ChildItem(i,2,"WebEdit",index).Set strNumber
...
The fourth argument of the ChildItem method on a WebTable is the index of the returned childitem (WebEdit in this case) on that row / column combination.
So, what is happening: On the first found row with content (nr. 2), the index becomes 0, but on the second iteration of the for loop, the index becomes 1. QTP cannot find a second WebEdit object on that row / column and will return an error.
So, use index = 0
to solve that one.
For your first question, what happens if you change the order: Set the WebCheckBox first and then the second WebEdit:
objFrame.WebTable("WebTable").ChildItem(i,2,"WebEdit",index).Set strNumber
objFrame.WebTable("WebTable").ChildItem(i,4,"WebCheckBox",index).Set strPreferred
objFrame.WebTable("WebTable").ChildItem(i,3,"WebEdit",index).Set strNumber2
Can you tell what is happening now?
This is an answer I wrote before, updated to your situation:
Can you see the BHOManager class in IE?
Go to IE > Tools > Manage Add-ons, make sure BHOManager class
(Browser Helper Object) from Mercury Interative Corporation is
enabled.
It is recommended to disable other add-ons, such as third-party toolbar, add-
ons from anti-virus companies, etc. This is to make sure nothing is
preventing QTP from hooking into the browser.
If this is all the case, you re-register the BHOManager again:
Close IE and all iexplore.exe processes in the task manager
Close QTP (or restart your machine)
Go to Start > Run, unregister and register BHOManager.dll:
regsvr32 -u c:\WINDOWS\system32\BHOManager.dll
regsvr32 c:\WINDOWS\system32\BHOManager.dll
When this solves your second run, you know there is something wrong with the BHO in IE: They are not started correctly or they are refused the second time. Maybe a more strict IT policy or an eager virus scanner that removes all not recognized browser add ins.
Best Answer
This error is returned when the cell exists and there are childobjects of type link, but not with this index (3). Try to see if you can confirm that the link with index 0 exists by:
To see where that link is placed on your page, you can use
EditLink.Highlight
From this point you can start debugging to see if the link with index 1, 2 and finally 3 exists.