HI Guys,
Been having a lot of success lately with automating IE tasks using VBA. HOWEVER, I have one drop down menu I just cannot get the code right to select my item.
I can successfully identify the drop down and click on it, but cannot select an option. I have tried selectedindex, value =, I also altered the inner text with a FireEvent Onchange but it would not recognise it. I also used send keys to manually navigate the drop down but this failed when I introduced a loop later...
Been having a lot of success lately with automating IE tasks using VBA. HOWEVER, I have one drop down menu I just cannot get the code right to select my item.
I can successfully identify the drop down and click on it, but cannot select an option. I have tried selectedindex, value =, I also altered the inner text with a FireEvent Onchange but it would not recognise it. I also used send keys to manually navigate the drop down but this failed when I introduced a loop later...
VBA Code:
Sub Toggle()
Dim I As Long
Dim href As String
Dim URL As String
Dim URL2 As String
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Dim HWNDSrc As Long
Dim htmlSelect
Set IE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
URL = "http://taddsmigui.nat.bt.com/TADDSGUI/#"
URL2 = "http://taddsmigui.nat.bt.com/HHTGUI/"
IE.Visible = True
I = 2
Do While Not IsEmpty(Worksheets("Test Data").Cells(I, 7).Value)
IE.Navigate URL2
Sleep 2000
IE.document.getElementsByClassName("ui-selectmenu-text")(1).Click
VBA Code:
<select name="periodNumDaysBefore" id="periodNumDaysBefore" style="width: 128%; display: none;">
<option value="0">Today Only</option>
<option value="1">Last 2 Days</option>
<option value="7">Last Week</option>
<option value="14">Last Fortnight</option>
<option value="30">Last Month</option>
<option value="60">Last 2 Months</option>
<option value="90">Last 3 Months</option>
<option value="-1">User Defined Range</option>
<option value="Base">Baseline</option>
</select>
<span tabindex="0" class="ui-selectmenu-button ui-widget ui-state-default ui-corner-all" id="periodNumDaysBefore-button" role="combobox" aria-disabled="false" aria-expanded="false" aria-haspopup="true" aria-labelledby="ui-id-1" aria-activedescendant="ui-id-1" aria-owns="periodNumDaysBefore-menu" style="width: 243px;" aria-autocomplete="list"><span class="ui-icon ui-icon-triangle-1-s"></span><span class="ui-selectmenu-text">Today Only</span></span>
<span class="ui-icon ui-icon-triangle-1-s"></span>
<span class="ui-selectmenu-text">Today Only</span>