PDA

View Full Version : [SOLVED] VBA Excel: Error 424 in "For Each" caused by FireEvent ("onchange")



junior_88
12-04-2014, 04:13 AM
I have a problem with next code:

Set chooseLanguage = IE.Document.getElementById("L_langue")
chooseLanguage.selectedindex = jezyk 'jezyk value = 0 or 1
chooseLanguage.FireEvent ("onchange")



Do
DoEvents
Loop Until IE.ReadyState = 4 Or IE.Busy

'Take to /Listbox

Set Products = IE.Document.getElementById("listec")
For Each ele In Products
ListBox1.AddItem ele.innerText

Error 424 is appears and hightligh the error in 'For Each ele In Products' line...


When I remove line 'chooseLanguage.FireEvent ("onchange")' then
Set Products = IE.Document.getElementById("listec")
For Each ele In Products
ListBox1.AddItem ele.innerText works correct.

What is the reason? How to make action FireEvent ?

Aflatoon
12-04-2014, 06:32 AM
Try removing the

Or IE.Busy
part

junior_88
12-04-2014, 07:45 AM
It does not help. Any idea ?

Aflatoon
12-04-2014, 09:17 AM
No, since I have no idea what your onchange event does.

junior_88
12-05-2014, 01:45 AM
I found the solution.


Instead of code

Do DoEvents Loop Until IE.ReadyState = 4 Or IE.Busy[/CODE]
I pute next formule:

Do While IE.Busy
Application.Wait DateAdd("s", 5, Now)
Loop

Probably the website has blocking properties against some kinds of web scriping.


Thanks for collaboration.