Re: Navigate Internet Explorer using VBA

codactu

New member
Local time
Today, 09:01
Joined
May 5, 2010
Messages
6
Re: Navigate Internet Explorer using VBA

Hello, i'm a new user and i appreciate your post about how to navigate IE using VBA.
I have a trouble with a submitting form and i would like to know your opinion about it.
The link of the web site is http://www.assurland.com/Pages/Resultat/Restit.aspx?wait=1&crm=1&product=EMPR&qid=BTKOPEOEXIEAHHGDD

and i cannot submit the form "Cliquez ici pour comparer en détail".
Here is my code:

For Num = 0 To IE.Document.getElementsByTagName("TD").Length - 1
If IE.Document.getElementsByTagName("TD").Item(Num).className = "al_compare" Then

IE.Document.getElementsByTagName("TD").Item(Num).Click

'MsgBox IE.Document.getElementsByTagName("TD").Item(Num).tagName
'MsgBox IE.Document.getElementsByTagName("*").Item(Num).innerText
Exit For
End If
Next

Can you give me an advice ?

Regards
Codactu.
 
Re: Navigate Internet Explorer using VBA

Hello codactu,

you try to click the TD element with code, but I think that the link is located in the contained DIV element. If you inspect the page with Firefox+Firebug you will see that the TD element spans the whole page whereas the DIV contains only the link on the left side.
I do not know the DOM model from the top of my head, but there should be something like getChildNode() to navigate to the DIV child of the TD element.

HTH
Thomas
 
Re: Navigate Internet Explorer using VBA

Thank you Thomas,
"Ajetrump" has given me the solution. It is: "IE.Document.getElementsByTagName("div").Item(15).Click".

Have a good day,
Codactu.
 
Re: Navigate Internet Explorer using VBA

Good to hear that you got it working.

Just one hint: Finding a named element and navigate from there to the (only) child should be a bit more robust against site redesigns than picking the nth DIV item. For a one shot solution the approach is perfectly ok, but if it shall work for a longer time, you might want to consider the alternate approach.

Thomas
 

Users who are viewing this thread

Back
Top Bottom