2

I am trying to use VBA to click on a Java script button on the following website: http://www.ura.gov.sg/realEstateIIWeb/transaction/search.action

I'm trying to get the vba to select a project and then click on the button labelled Add and then the button labelled search in the web link above.

I have managed to get the VBA to open the website and select the project, but some how I am unable to get the VBA to click on the "Add" button and "Search" button

Sub DLDATA()

Dim MAS As Object
Dim STYR As Object
Dim DLD As Object
Dim XLD As Object
Dim form As Variant, button As Variant

Set MAS = CreateObject("InternetExplorer.application")

With MAS

.Visible = True

.Navigate Sheets("Property Value").Range("B30").Value ' Navigate to website

Do Until .ReadyState = 4
    DoEvents
Loop

Set STYR = MAS.Document.all.Item("projectNameList")
STYR.Value = Sheets("Property Value").Range("A1").Value ' Select name of property based on name in cell A1.    

Set XLD = MAS.Document.all.Item("addOpt")
XLD.Value = Sheets("Property Value").Range("A1").Value


End With

End Sub

1 Answer 1

1

this works for me

Sub test()

URL = "http://www.ura.gov.sg/realEstateIIWeb/transaction/search.action"

Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.navigate URL

Do Until (ie.readyState = 4 And Not ie.Busy)
    DoEvents
Loop

Set STYR = ie.Document.all.Item("projectNameList")
STYR.Value = Sheets("Property Value").Range("A1").Value ' Select name of property based on name in cell A1.

Set Results = ie.Document.getElementsByTagName("input")   ' find and click the "add" button
For Each itm In Results
    If InStr(1, itm.outerhtml, "addOpt", vbTextCompare) > 0 Then
        itm.Click
        Exit For
    End If
Next

ie.Document.getElementByID("searchForm_0").Click   ' click the "search" button 

Do Until (ie.readyState = 4 And Not ie.Busy)
    DoEvents
Loop

' do whatever

End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Sooooo Much!! At first this didn't work for me, but I added Application.Wait (Now() + TimeValue("00:00:02")) before the search function and it worked. Thank you very much!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.