How Can I Click an un-name IE button via VBA

A

angsoka

Hi all.
I am trying to control a website from Excel VBA. It has page sourc
below:

<FORM class=chooser_form id=chooser_form name=chooser_form
onsubmit="return false;" action=http://www.example.com/ method=post>
<INPUT type=hidden value=en name=lang>
<DIV class=entry_url_out>
<INPUT class=entry_url name=URL>
</DIV>
<DIV class=selector_site_2_out>
<SELECT class=selector_site_
onchange=change_info(document.chooser_form.site.selectedIndex)
name=site>
<OPTION value=Option1>Option1</OPTION>
<OPTION value=Option2>Option2</OPTION>
</SELECT>
</DIV>
*<INPUT class=entry_submit onfocus=this.blur()
onclick=buttonDownload() type=submit>
*</FORM>


That website change a text into another text. Normaly under IE, we mus
type on the input box in that website, and click the button. Afterwards
that web show the result.

By this code below, I have succeed to enter a text in to the input box
but I can't "click" in the button because that button didnt have a name
Here is my code

Private Sub OpenWebPageAndInput_Click()
Dim objIE As Object
On Error GoTo error_handler
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Navigate "www.example.htm"
Do While .Busy: DoEvents: Loop
Do While .readyState <> 4: DoEvents: Loop
.Visible = True
With .Document.Forms("chooser_form")
.URL.Value = "test"
.submit '< this line was error

End With
End With
Set objIE = Nothing
Exit Sub
error_handler:
MsgBox ("Unexpected Error, I'm quitting.")
objIE.Quit
Set objIE = Nothing
End Sub


I have tried SendKeys "{ENTER}", True but it was fail too
I guess, that website use a Javascript or Ajax to send the input dat
to function "buttonDownload". Please help
 
N

NickHK

So if you can capture the URL that is sent, so you know its structure.
Then just build you own and send that instead.

NickHK
 
A

angsoka

Thank you for your quick reply. But I didnt understand your answer
because I am not an expert on HTML. This bring me to another question,
can we enter a javascript function via VBA without open that website?
What is the code in VBA?

For example
<INPUT .... onClick=dothis() type=submit>
<A HREF="newpage.htm" onClick="dothis();return false">Click Here!</A>
<A HREF="dothis()" >Click Here!</A>

I want to learn that, so do you have any suggestion or link, where i
must start from
 
N

NickHK

You would be better in a java or HTML group, as this is now nothing to do
with Excel.

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top