我正在尝试使用VBA点击以下网站上的Java脚本按钮:http://www.ura.gov.sg/realEstateIIWeb/transaction/search.action
我正在尝试让vba选择一个项目,然后点击标有Add的按钮,然后单击上面web链接中标记为search的按钮。
我设法让VBA打开网站并选择项目,但有些我无法让VBA点击“添加”按钮和“搜索”按钮
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")
使用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
答案 0 :(得分:1)
这对我有用
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