I have been trying to select a drop down list in a web page using VBA, which I'm new to. In HTML the drop down menu is stated as Button and not Select. Here is the HTML code:
<span class='btn-group'>
<button id='str_listing-btn' name='str_listing-btn' type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown' data-value='For Sale'>
For Sale
<span class='caret' style='margin-left:5px;'>
</span>
</button>
<ul class='dropdown-menu wptk_crud_dropdown' id='str_listing' data-value='str_listing' role='menu'>
<li>
<a href='#' data-value='For Sale'>For Sale</a>
</li>
<li>
<a href='#' data-value='For Rent'>For Rent</a>
</li>
<li>
<a href='#' data-value='Wanted To Buy'>Wanted To Buy</a>
</li>
<li>
<a href='#' data-value='Wanted To Rent'>Wanted To Rent</a>
</li>
</ul>
</span>
I have tried a few VBA codes to select one of the options. Below is the latest code that I have used but after running it nothing seems to happen to the drop down menu:
Private Sub InsertPropwall_Click()
Dim objIE1 As Object
objIE1.navigate ("http://www.propwall.my/classifieds/post_ad?action=add")
Do
DoEvents
Loop Until objIE1.ReadyState = 4
objIE1.Document.getElementById("str_listing-btn").Value = "For Rent"
Do
DoEvents
Loop Until objIE1.ReadyState = 4
End Sub
See Question&Answers more detail:os