Select from a drop down menu using VBA

Johnnyv015

New Member
Joined
Sep 8, 2014
Messages
9
Hello, I am trying to click on a specific option in a dropdown on an IE page and I am having trouble with the code for this. As of now this is the code I have to access the page.

Code:
 Dim HTMLDoc As HTMLDocument
 Dim MyBrowser As InternetExplorer
 Sub MCLogin()

  Dim MyHTML_Element As IHTMLElement
  Dim MyURL As String
  On Error GoTo Err_Clear
  MyURL = "***********"
  Set MyBrowser = New InternetExplorer
  MyBrowser.Silent = True
  MyBrowser.navigate MyURL
  MyBrowser.Visible = True
  Do
  DoEvents
  Loop Until MyBrowser.readyState = 4
  Set HTMLDoc = MyBrowser.document
  HTMLDoc.all.txtLogonID.Value = "*******"
  HTMLDoc.all.txtPswd.Value = "*********"
  For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
  If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
  Next
Err_Clear:
  If Err <> 0 Then
  Err.Clear
  Resume Next
  End If
  Resume Next

  
  End Sub

<!-- END TEMPLATE: bbcode_code -->Now I need to click on a drop down and select an option from a list(in the same window.) Here is the HTML for the Dropdown box. <!-- BEGIN TEMPLATE: bbcode_html -->

HTML:
 -Select- Business Review Close Daily Dashboard Close Quality Assurance Close Reporting Close Weekly Dashboard Closing Employee Lookup Job Counts Josh Analysis Multi-Property New Hire Online Reservation Phone THD Finance Tech Time Reports

Can anyone get me moving in the right direction on this project?

Thanks! John
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Johnnyv015

New Member
Joined
Sep 8, 2014
Messages
9
Any ideas? or any other information needed for an answer on this? Also I did notice when I copy and pasted the HTML it removed the quotes.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,606
Messages
5,597,134
Members
414,128
Latest member
Jorglo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top