?
Solved

VB 6.0 webbrowser control to automate html dropdown selection

Posted on 2005-05-09
5
Medium Priority
?
671 Views
Last Modified: 2013-12-25
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>
0
Comment
Question by:cybeh
  • 4
5 Comments
 
LVL 10

Expert Comment

by:edwardiii
ID: 13961739
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"

     
0
 
LVL 1

Author Comment

by:cybeh
ID: 13967637
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.


0
 
LVL 10

Accepted Solution

by:
edwardiii earned 200 total points
ID: 13972379
I see what you mean.  For "select-one" element types we can do the following:

    MsgBox WebBrowser1.Document.Forms(0).Elements(1).selectedIndex  'gives name of currently selected option
    WebBrowser1.Document.Forms(0).Elements(1).selectedIndex = 2        'sets drop-down to option 2, or "Area B".
0
 
LVL 10

Expert Comment

by:edwardiii
ID: 13972406
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).
0
 
LVL 10

Expert Comment

by:edwardiii
ID: 14566963
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.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question