VB Internet Controls - How to click a button with no name

Posted on 2005-05-04
Last Modified: 2013-12-25
Hi there, I know how to enter in text to a website, and then click a button with this code.

wbrInternet is my Web Browser im using in my program.

I then do this:

      wbrInternet.document.all.item("textboxname").value = "Test"

and that works fine. Fine if the button you want to click HAS A NAME.

This is the following HTML code of a site I wish to enter text into, and click the button. the button doesnt have a name and so I cant click it.

<form method="get" action="index.php" name="searchForm">
 <input name="text" type="text" size="30" autocomplete="off">
<select name="booke">
 <option value="vb6">Visual Basic 6</option>  
<input type="submit" value="Search Book">


How can I search that? I know I can do

wbrInternet.document.all.item("text").value = "Value I want"

but how do I do the click part?

Please help me.

Question by:invader_RMUK
    LVL 10

    Expert Comment

    Hi, invader_RMUK.

    See this post's accepted answer--instead of trying to click a button, try submitting the form that your items are on:


    And if that's no go, try looping through the elements/items and clicking each one, until you get the desired response.  Then note the details/id of the one that worked.
    LVL 17

    Expert Comment

    Private Sub Command1_Click()
        'WebBrowser1.Document.Forms("searchForm").Item(2).Value = "Search Book"
        Call WebBrowser1.Document.Forms("searchForm").Item(2).Click
    End Sub

    If the HTML is different for the Form (additional elements), then you may need to change (2) to the proper index.
    LVL 10

    Accepted Solution

    Slight modification--to submit "searchForm", which is equivalent to clicking the "Submit" button (if so labelled):  
    LVL 17

    Expert Comment

    Automating the submission of the form may cause problems if there are associated scripts (such as for OnClick event) for the Submit buttons. If the scripts do not execute, it may disrupt the data to be submitted. Another scenario may exist for forms that have different Submit-button elements as different values could be submitted.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    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…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now