Clicking a Java script button using excel

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

Answers


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

Need Your Help

Status bar won't disappear

hidden statusbar ios7 xcode5

I'm creating an application and I want the status bar hidden. When I test the app, the status bar is hidden whilst the splash screen is shown, but once the app is fully loaded, the status bar reapp...

.Net - using FileIOPermission with mask in file name

.net security file-permissions mask

I would like to apply FileIOPermission on set of files using mask in file name, ex. on all txt files in folder C:\TMP: