i hope you guys can help me :)
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
> will you mary me?
> omg, you are of such help m8!!
If you are referring to myself and my reply, the answer is "Nope!" :-)
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.