[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 448
  • Last Modified:

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

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.

  • 2
  • 2
1 Solution
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.
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.
Slight modification--to submit "searchForm", which is equivalent to clicking the "Submit" button (if so labelled):  
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now