'VBA how to fill in search bar with ID?

Web page has the following HTML without an ID - how do I set the value of the form?

<input name="loanxFindBorrower" onkeypress="if((window.event&amp;&amp;window.event.keyCode==13) || 
(event.which&amp;&amp;event.which==13 )){ findByBorrowerAction()}" type="text" size="25" value="">

I've tried

 IE.Document.getElementByTagName("loanxFindBorrower").Value = "New Value"

Aswell as

IE.Document.getElementByTagName("loanxFindBorrower").Focus
IE.Document.getElementByTagName("loanxFindBorrower").Value = "NewValue"

Any help would be much appreciated



Solution 1:[1]

You should use getElementsByName() to get the element. It returns a collection, you'll need to specify the index to get the element you want.

For example, if it's the first element with name "loanxFindBorrower" in the page, the index is 0:

IE.Document.getElementsByName("loanxFindBorrower")(0).Value = "New Value"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yu Zhou