Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fill in internet forms silently

0 views
Skip to first unread message

ruudv...@gmail.com

unread,
Mar 1, 2006, 12:44:21 PM3/1/06
to
Hi!
I made a program with VB6.0 to edit some text and then send it to an
internet database. but to insert it into the internet database, i need
to fill in an internet form.
I wanna do this silently to help my client, but I have no idea how to
fill in a textarea at some internet website and press a button there.

i hope you guys can help me :)

Desertphile

unread,
Mar 1, 2006, 8:39:40 PM3/1/06
to

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

ruudv...@gmail.com

unread,
Mar 2, 2006, 3:40:55 PM3/2/06
to
will you mary me?
omg, you are of such help m8!!

Desertphile

unread,
Mar 2, 2006, 6:46:10 PM3/2/06
to
ruudv...@gmail.com wrote:

> will you mary me?
> omg, you are of such help m8!!

If you are referring to myself and my reply, the answer is "Nope!" :-)

Unknown

unread,
Jun 11, 2006, 10:15:46 PM6/11/06
to
On 1 Mar 2006 17:39:40 -0800, "Desertphile" <deser...@hotmail.com>
wrote:

When I tried to use this code, I have problems.

WB.Document.All(i).TagName generates this error
"Object doesn't support this action"

WB is the WebBrowser on the form.

Please tell me what I am doing wrong. When I typed the "." after WB,
I got the list of all properties, but when I put the "." after
document, I did not see the properties of the document so I typed
All(i) and then ran it to no avail.

0 new messages