How to click on HTML <li> element from VBA

spikepl

Eledittingent Beliped
Local time
Today, 03:35
Joined
Nov 3, 2010
Messages
6,142
I have this .NET generated HTML page, where I from VBA need to click on the list item Choice2.

Code:
<ul class="level1"> 
 <li><a class="level1 selected" href="#" onclick="__doPostBack('ctl00$Menu_Admin','Frontpage')">Frontpage</a></li>
<li><a class="level1" href="#" onclick="__doPostBack('ctl00$Menu_Admin','Choice2')">Choice2</a></li>
<li><a class="level1" href="#" onclick="__doPostBack('ctl00$Menu_Admin','Choice3')">Choice3</a></li>
<li><a class="level1" href="#" onclick="__doPostBack('ctl00$Menu_Admin','Choice4')">Choice4</a></li> 
        </ul>

If you know how to do that, or can point me to a resource that can help, please write here. I need either to click on the desired element from VBA, or probably to just run the associated postback handler, and not too sure how to do that from vba

I know how to click on named elements, eg:

Code:
 Set ipf = IE.Document.all.Item("ctl00$MainContent$LoginUser$LoginButton")
 ipf.Value = "submit"
 ipf.Click
 
jdraw - i remembered that that link existed, but for some reasons I couldn't find it. Thanks. We'll see what I make of it.
 
Actually, what I needed to click on was a link (ie <a>-tag) inside my second <li>

This can be done with

oBrowser.Document.getElementsByTagName("a").Item(2).Click

since i only had links inside the list.
 

Users who are viewing this thread

Back
Top Bottom