Excel Automate IE with Excel onClick text

Joined
May 21, 2012
Messages
3
Reaction score
0
Hi All,
I have been automating IE 7 with excel 2007 VBA in XP for a couple of years and have hit a stumbling block. I need to click on a text box to move a secured site forward in the process to edit a record. The text field that is NOT active NOR is it a hyperlink, but has an unnamed onClick event. As this is a secure site, the URL path never changes.

Attached is the Source Code with alias names/values for the text I need to click,
and my vba to get to this point:

How can I click this item with vba code?
 

Attachments

Figured it out! :)

I was trying to click on a row of a table. This row had no name, but did have a Class and Title with an onClick="postURL...."
So what you need to do is loop through all items on the page until you find the class that equals the name. in my case, <tr class="shadedRow"

First you need to identify what element to loop through:

Dim inputElements As Object
Dim inputElement As IHTMLElement
Set inputElements = appIE.Document.getElementsByTagName("TR")

I selected "TR" above because <tr class="shadedRow". if you wanted to search through tables <table, then just type "table" instead of "TR".

For Each inputElement In inputElements
If inputElement.className = "shadedRow" Then
inputElement.Click
GoTo A
End If
Next inputElement

again, if you're searching for a tablename, change the if statement in the code above to tableName = "yourtablename"

Hope this helps someone other than me.
 
I need to click on a text box to move a secured site forward in the process to edit a record.

If you are referring to the point that I clicked an item with a class of "shadedRow" this is because the text field was in a table, and the field was in that row. turns out I only needed to click on the row, not necessarily the text itself.

Did you have a question regarding my solution?
 
I'm attempting to log into a website automation. My code works taking input from a userform and inputting the username and password to the site but won't "click" login.

This the code from the site but I can't figure out which is that actually button.

Can anyone help?
 

Attachments

  • Untitled.webp
    Untitled.webp
    32.3 KB · Views: 121
Back
Top