VBA selecting radio button and search text and getting data

vikas0903

New Member
Joined
Dec 17, 2013
Messages
20
Hi All,
Thanks in advance for reading and giving your time.

I am trying to access this page and automate search of lot#:
"https://www.smarteda.qld.gov.au/pools/properties/propertySearch.action"

I am using MSXML to do this:

Code:
Sub Getlot()
 
Dim xml As Object ' MSXML2.XMLHTTP
Dim html As Object ' MSHTML.HTMLDocument
Dim imgLinks As Object ' MSHTML.IHTMLElementCollection
Dim imgLink As Object ' MSHTML.IHTMLElement
Dim result As String
 
  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")
 zipCode = "2RP219592"
  With xml
    .Open "GET", "https://www.smarteda.qld.gov.au/pools/properties/propertySearch.action?lot_rad=""TRUE""&lotplan_number=" & zipCode, False
    .Send
  End With
 
  result = xml.responseText
 
 Cells(1, 1).Value = result
  
End Sub

But this code is not able to click on radio button (to select lot#) and then enter lot# in input box. So basically I am NOT getting searched result in "result" string.

[Above code is not mine, and I have mainly used codes from "http://www.jpsoftwaretech.com/an-exploration-of-ie-browser-methods-part-ii/" and few other sources to write it.]

Regards!
Vikas
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi all,
After researching for more, I have improved the code. I am able to send the lot# but still I am NOT able to select radio button, submit form and get results. [It appears that I needed to use POST instead of GET]

Code:
Sub Getlot()
 
Dim xml As Object ' MSXML2.XMLHTTP
Dim html As Object ' MSHTML.HTMLDocument
Dim imgLinks As Object ' MSHTML.IHTMLElementCollection
Dim imgLink As Object ' MSHTML.IHTMLElement
Dim result As String
Dim params As String
params = "lot_rad=1&lotplan_number=2RP219592"
 
  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")
 zipCode = "2RP219592"
  With xml
    .Open "Post", "https://www.smarteda.qld.gov.au/pools/properties/propertySearch.action", False
     .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    .send "lot_rad=true&lotnumber=40SP139152"




 ' End With
     i = 0 'wait until data has been downloaded
    Do While i = 0
        If .readyState = 4 Then
            If .Status = 200 Then Exit Do
        End If
        DoEvents
    Loop
    Sleep 2000


 End With




  result = xml.responseText
 
 Cells(1, 1).Value = result 
End Sub

Please help.
 
Upvote 0
Some more update. I am able to select radio button and send input. BUT STILL NOT GETTING RESPONSE FROM SERVER.
Please help. [New code is below].

Code:
Sub Getlot()
 
Dim xml As Object ' MSXML2.XMLHTTP
Dim html As Object ' MSHTML.HTMLDocument
Dim imgLinks As Object ' MSHTML.IHTMLElementCollection
Dim imgLink As Object ' MSHTML.IHTMLElement
Dim result As String
Dim params As String


 
  Set xml = CreateObject("MSXML2.XMLHTTP.6.0")


  With xml
    .Open "POST", "https://www.smarteda.qld.gov.au/pools/properties/propertySearch.action", False
     .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

.send "method=lotplan&lotnumber=40SP139152"
    While .readyState <> 4
      .waitForResponse 200
    Wend


  Sleep 10000
 End With
  result = xml.responseText
 
 Cells(1, 1).Value = result
  
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,504
Messages
6,125,185
Members
449,213
Latest member
Kirbito

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