Link to home
Start Free TrialLog in
Avatar of cybeh
cybeh

asked on

VB 6.0 webbrowser control to automate html dropdown selection

I had placed a webbrowser control in my form


Private Sub Form_Load()
    WebBrowser1.Navigate2 "http://www.abc.com/" 

    Do While WebBrowser1.Busy = True
      DoEvents
    Loop

    WebBrowser1.Document.Forms(0).Username.Value = "debehs"
End Sub

While there is a combo box with the name "cmbArea", and I need to give the answer as "Area A". I tried to code it this way but no luck.


WebBrowser1.Document.Forms(0).cmbArea.Value = "Area A"


Please Advice. Thanks in advance !!!

================================

Web coding

=================================

<select name="cmbArea">
<option value="" selected>
<option>Area A
<option>Area B</select>
Avatar of edwardiii
edwardiii

Hi, cybeh.

I'm not seeing the Combobox you mention; maybe I'm just missing it, but I am being redirected to this URL:

     http://abc.go.com/

In any event, the usual syntax to write to a form element value is:
     
     WebBrowser1.Document.Forms(0).Elements("cmbArea").Value = "Area A"

     
Avatar of cybeh

ASKER

Hi,

Thanks for the reply. http://www.abc.com is just a sample.

Please have a look on this form
http://www.teccalibre.com/test.html

The code
WebBrowser1.Document.Forms(0).Elements("cmbArea").Value = "Area A"
will work if the page was coded with
<select name="cmbArea">
<option value="" selected>
<option value = "Area A">Area A
<option value = "Area B">Area B</select>

Please advice.


ASKER CERTIFIED SOLUTION
Avatar of edwardiii
edwardiii

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
By the way, full details on all such options can be found here:

http://www.activevb.de/tutorials/tut_browsertags/browsertags.html (it's in German, and the translation isn't perfect, but the code examples are excellent).
For those that don't speak German, you can go to www.google.com/translate_t, paste the URL above in the "Translate a web page" textbox, and much of the Web page will be translated. For the remainder, or to translate a small part of the text, drop it into the "Translate text" textbox of the Google page.