2
votes

I'm using IE version 9 and trying to click "submit" button using VBA. I've tried many ways but getting no luck.

Can anyone please help? below is the element code of button. Please note that "on click" doesn't have space in real codes.

Button code :

<input type = submit value = " Submit " on click= "return submitDWAC(this.form)">

I've already tried below, but they are not working.

.Document.getelementbytagname("Submit").Click   

.Document.all("Submit").click

Sendkey {ENTER}, TRUE 

Please assist.....

2

2 Answers

1
votes

The tag name is <input not submit but an easier way to do this is the use the form.submit() method:

.document.forms(0).submit

If there is only one form on the page then this should do the trick, otherwise you will need to enumerate through the form objects and test each one to see which one you want to submit.

1
votes

For starters .getelementbytagname does not exist so this:

.Document.getelementbytagname("Submit").Click   

would fail. The method is .getElementsByTagName. There is a "s" after element, indicating that a collection of elements is returned.

The HTML you show is of an input tag as mentioned in the other answer. Submitting the form is a good way to go, or you can target that input tag and by its type attribute, using a CSS selector, and go with:

.document.querySelector("input[type=submit]").Click