07-29-2011, 11:16 PM
One problem I see (but not the cause of your crash) is that in your loop, "i" starts at "1". Then you set "itemname" to ...GetItem(i+1), so the first element you get is element #2; item #1 gets ignored. Maybe that's by design.
It sound to me like it is getting a value via "GetItem(i+1)" that cannot be selected in the next line for some reason. I ran your code on our test web site on a couple of different dropdowns and it worked OK.
To help you find the error, try changing your code to work like this until you find the problem:
.................
.................
and set a breakpoint on the line "x=1". When the debugger breaks on that line, you can examine "Itemname" and see what it is. It sounds like when this happens that the value for "Itemname" is not on the list for some reason.
It sound to me like it is getting a value via "GetItem(i+1)" that cannot be selected in the next line for some reason. I ran your code on our test web site on a couple of different dropdowns and it worked OK.
To help you find the error, try changing your code to work like this until you find the problem:
.................
Code:
For i = 1 To ListSize-1
Itemname =Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").GetItem(i+1)
Err.Number=0
On Error Resume Next
Browser("MLSListings.com").Page("MLSListings.com").WebList("regions").Select Itemname
If Err.Number <> 0 Then
x=1
End If
and set a breakpoint on the line "x=1". When the debugger breaks on that line, you can examine "Itemname" and see what it is. It sounds like when this happens that the value for "Itemname" is not on the list for some reason.