Hello Excel Forum,
This is my first post. I'm very new to HTML and have a little bit of experience with VBA. I am trying to navigate through a webpage so that I can eventually grab the table from the page.
There is a multi-select dropdown menu on the page similar to the drop down menu in the following link.
http://www.w3schools.com/tags/tryit....elect_multiple
I need to be able to select multiple values in the drop-down menus and then submit the search. There are multiple drop-down menus to select from. One drop menu refers to "State" and the other to "Chain". Currently, I am able to select one drop-down menu item and submit the search which can be seen in the code below.
Help is greatly appreciated! Thanks!
VBA:
The HTML for the "State" ID can be seen below.![]()
Sub Navigate_Webpage() Const cURL = "website" Const cUsername = "username" Const cPassword = "password" Dim IE As InternetExplorer Dim doc As HTMLDocument Dim LoginForm As HTMLFormElement Dim UserNameInputBox As HTMLInputElement Dim PasswordInputBox As HTMLInputElement Set IE = New InternetExplorer IE.Visible = True IE.Navigate cURL Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop Set doc = IE.Document Set LoginForm = doc.forms(0) Set UserNameInputBox = LoginForm.elements("login") UserNameInputBox.Value = cUsername Set PasswordInputBox = LoginForm.elements("password") PasswordInputBox.Value = cPassword IE.Document.forms(0).submit Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop IE.Navigate "Navigate to page on website once logged in" Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop Set doc = IE.Document With doc With .getElementById("State") .Value = "OR" .Focus .FireEvent "onchange" End With With .getElementById("Chain") .Value = "LV" .Focus .FireEvent "onchange" End With Set tags = IE.Document.getElementsByTagName("Input") For Each tagx In tags If tagx.Value = "Search" Then tagx.Click Exit For End If Next End With End Sub
![]()
<select name="State" id="State" size="7" multiple="true"> <option value="" >-- All --</option> <option value="AL" >Alabama</option> <option value="AK" >Alaska</option> <option value="AB" >Alberta</option> <option value="AZ" >Arizona</option> <option value="AR" >Arkansas</option> <option value="BC" >British Columbia</option> </select>
Bookmarks