3

I am editing a vba program and want to code the vba to click on a button in a webpage. The html for the button is:

<input type="image" src="/lihtml/test_button3.gif" align="left" alt="File_Certificate_Go"/>

I imagine I would have to set a variable to getElementBy??? and then variable.click, but I can't figure out how exactly to get the element (because it doesn't have a name or id, and I can't give it one because it is not my webpage).

Any help is greatly appreciated!

2 Answers 2

3

Perhaps something on the lines of:

Set tags = wb.Document.GetElementsByTagname("Input")

For Each tagx In tags
    If tagx.alt = "File_Certificate_Go" Then
        tagx.Click
    End If
Next

Where wb is the WebBrowser control.

Sign up to request clarification or add additional context in comments.

Comments

2

Is there a reason you couldn't give the element an id?

i.e.:

<input id='myButton' type=image src="/lihtml/test_button3.gif" align=left alt=File_Certificate_Go> 

then:

document.getElementById('myButton').click()

edit: Based on your comment, you'd have to grab all input elements on the page, and then cycle through them looking for the one that makes your input unique:

var elms = document.getElementsByTagName("input"); 
for (var i=0; i< elms.length; i++) 
    if(elms[i].src = '/lihtml/test_button3.gif') { elms[i].click(); }

Something along those lines anyway

1 Comment

I cannot change the html because it is not my webpage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.