Select from a drop down menu using VBA

Johnnyv015

New Member
Joined
Sep 8, 2014
Messages
11
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
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,377
Members
448,955
Latest member
BatCoder

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
Back
Top