I'm having trouble navigating a website using vba macro. Once logged in to the website, I need to be able to do the following:
1) Select SEARCH ----> CUSTOM SEARCH/REPORT
2) Wait until new page loads then, Select "DaysOnMarket" from "Saved Searches" list.
3) Wait until new page loads then, select just "All" for the Status, place a 1 in the "Min" and "Max" txt fields, and click on "Search"
I've spent hours trying to figure this out already (specifically on how to select the pull down menu choice). Any help in pointing me in the right direction will be greatly appreciated. Thanks in advance.
1) Select SEARCH ----> CUSTOM SEARCH/REPORT
2) Wait until new page loads then, Select "DaysOnMarket" from "Saved Searches" list.
3) Wait until new page loads then, select just "All" for the Status, place a 1 in the "Min" and "Max" txt fields, and click on "Search"
I've spent hours trying to figure this out already (specifically on how to select the pull down menu choice). Any help in pointing me in the right direction will be greatly appreciated. Thanks in advance.
Code:
Sub MLSData()
Dim IEApp As Object 'Variable for Internet Explorer Object
Dim IEhandle As Long 'Internet Explorer handle
Dim XLhandle As Long 'Excel handle
Dim UserN As Variant
Dim PassW As Variant
Dim btnInput As Object 'MSHTML.HTMLInputElement
Dim ElementCol As Object 'MSHTML.IHTMLElementCollection
'Identify HANDLE for current Excel
XLhandle = Application.hwnd
'Open up Internet Explorer session
Set IEApp = CreateObject("InternetExplorer.Application")
IEApp.Navigate ("[URL]http://ntreis.marketlinx.com/TempoCommon/Authentication/Login.aspx?ReturnUrl=%2f[/URL]")
IEApp.StatusBar = True
IEApp.Toolbar = True
IEApp.Visible = True
IEApp.Resizable = True
IEApp.AddressBar = True
'Wait until IE has finished loading itself.
Do While IEApp.busy: DoEvents: Loop
Do Until IEApp.ReadyState = 4: DoEvents: Loop
Application.Wait Now + TimeValue("00:00:01")
'Identify HANDLE for current Internet Explorer Window#1
IEhandle = IEApp.hwnd
'Enter username and password in textboxes
Set UserN = IEApp.Document.getElementsByName("LoginCtrl$txtLoginUsername")
If Not UserN Is Nothing Then
UserN(0).Value = "0537404"
End If
Set PassW = IEApp.Document.getElementsByName("LoginCtrl$txtPassword")
If Not PassW Is Nothing Then
PassW(0).Value = "will provide privately"
End If
' click 'Submit' button
Set ElementCol = IEApp.Document.getElementsByTagName("INPUT")
For Each btnInput In ElementCol
If btnInput.Value = "Login" Then
btnInput.Click
Exit For
End If
Next btnInput
'Wait for webpage to load
Do While IEApp.busy: DoEvents: Loop
Do Until IEApp.ReadyState = 4: DoEvents: Loop
Application.Wait Now + TimeValue("00:00:01")
End Sub