Chris Cooper Chris Cooper - 15 days ago 5
HTML Question

How to click on that form?

I am not familiar with html and I am trying to submit a form from VBA.
I managed to select it, but then is there a special command to send it ?

This is what the form looks like..

I tried to click on it to submit it, but this doesn't work.

IEDoc.getElementsByTagName("form")(0).Click


I know my attempts sound poor, but I was at first trying to click on element which had a onclick property which returns false and I didn't manage to get this to work.
I found an other solution which worked but made the whole code crash at some point, this solution was to use the SendKeys method. You can see the article

Running Click event with no result

my colleague posted about it

Any tips are welcome.

EDIT : Bigger picture of the HTML code with full form

Answer

This is how I'd go about it, using SO as the URL

Sub x()

Dim ie As SHDocVw.InternetExplorer
Dim f As MSHTML.HTMLFormElement

Set ie = New SHDocVw.InternetExplorer
ie.Visible = True
ie.navigate "http://stackoverflow.com/questions/tagged/vba"

Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy
    DoEvents
Loop

Set f = ie.document.getElementsByTagName("form")(0)
f.elements(0).value="SQL"
f.submit

End Sub