Re: submitting form in a internetcontrol
- From: desertphile@xxxxxxxxxxx
- Date: 31 May 2006 16:09:06 -0700
Nico wrote:
I have made an application to extract members from a member list on a
website (It's over 2000 members per website) Each member has a number I have
to fill in at a form at that website. So I made this application to automate
this a bit.
The old way: lookup member, copy paste it in Excel, transponate, and export
the record to Access and start all over again with next member. So you can
imagine i don't want to do that anymore...
Now back to my problem. I can get to the website, but I can't seem to start
the click button event(button is submit button) or form submit event. Can
anyone tell me how to do this?
It's easy. ;-) Using Microsoft's web browser ActiveX object (which
apparently in your follow-up message you said you were using), you need
merely navigate to the web page in question, programatically examine
that web page and determine the INPUT text boxes you are interested in
(via element number: see below URL), and determine what element number
the form's SUBMIT button is.
Once you know the HTML document's elements, you may then use the
object(element-number).Click event to "push" the SUBMIT button.
There is no error event called in this code
when run. He kind of ignores my submit code...
You will probably find my answer to a similar question useful.
http://groups.google.com/group/comp.lang.basic.visual.misc/msg/8a3aa3ec935dbbe8?dmode=source
Using Microsoft's web browser ActiveX control you will be able to
programatically fill out a HTML from on the 'net and then
programatically "push" the "submit" button on that form. You will also
be able to copy and save the information on the HTML document using the
..InnerText ot .OuterText property and then send it to MS Access (or
whatever).
WebBrowser1.Document.All will hold every element in a HTMP document.
You will wish to make a note of which element(s) are the form's text
boxes, and which element(s) are the form's buttons. Since a form
generally has only one "submit" button, but may have many text boxes,
you will need to write dowen (perhaps on a piece of paper) which
elements you are working with.
To list the elements, first navigate to the web site (via URL) in
question and then run a script to list the elements.
Private Sub Command1_Click()
Dim i As Integer
Open "C:\temp\Element-list.txt" For Output As #1
WebBrowser1.Navigate "http://holysmoke.org/"
Do
DoEvents
If WebBrowser1.Busy = False Then Exit Do
Loop
On Error Resume Next
For i = 0 To WebBrowser1.Document.All.length - 1
Debug.Print i, "Tag Name: ";
WebBrowser1.Document.All(i).TagName
Debug.Print i, "Text: "; WebBrowser1.Document.All(i).OuterText
Debug.Print i, "Type: "; WebBrowser1.Document.All(i).Type
Debug.Print i, "Value: "; WebBrowser1.Document.All(i).Value
Debug.Print
Print #1, i, "Tag Name: "; WebBrowser1.Document.All(i).TagName
Print #1, i, "Text: "; WebBrowser1.Document.All(i).OuterText
Print #1, i, "Type: "; WebBrowser1.Document.All(i).Type
Print #1, i, "Value: "; WebBrowser1.Document.All(i).Value
Print #1, ""
Next
Close
End Sub
For the text boxes, you are looking for the elements called "OPTION".
You will wish to fill those elements with the Value property
WebBrowser1.Document.All(-the-number-).Value = "Hello World"
For the submit button, you probably want the last "INPUT" element,
however if the HTML form has buttons after the button you want, you
will have to determine the actual element number. Once you find that
element number, you may use the .Click method to "push" that button.
WebBrowser1.Document.All(-the-number-).Click
In the example above, the holysmoke.org web page has HTML form with a
text box at element 121. The submit button is element 122. If I wanted
to fill out that text box I would add the line to my code:
WebBrowser1.Document.All(121).Value = "Bob Minton"
Then to submit that form, I would add:
WebBrowser1.Document.All(122).Click
Do
DoEvents
If WebBrowser1.Busy = False Then Exit Do
Loop
.
- Follow-Ups:
- Re: submitting form in a internetcontrol
- From: Nico
- Re: submitting form in a internetcontrol
- Next by Date: Re: Restriction
- Next by thread: Re: submitting form in a internetcontrol
- Index(es):