【发布时间】:2018-05-26 05:58:47
【问题描述】:
我正在使用 VBA 和 IE 自动提交表单。 我可以提交表单,但是,在提交表单后,我无法获得 IE 文档中标签的最新状态 这是我用于 URL http://www.tangoloans.co.uk/brokerform/?affl_id=216的代码
网址 = "http://www.tangoloans.co.uk/brokerform/?affl_id=216" recordCount = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).row
Set appIE = New InternetExplorer
appIE.navigate URL
Do While appIE.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Waiting ..."
DoEvents
Loop
appIE.Visible = True
Set Doc = appIE.document
Doc.getElementById("title").Value = .Range("A" & row)
Doc.getElementById("fname").Value = .Range("B" & row)
Doc.getElementById("lname").Value = .Range("C" & row)
Doc.getElementById("dobDay").Value = .Range("D" & row)
Doc.getElementById("dobMonth").Value = .Range("E" & row)
Doc.getElementById("dobYear").Value = .Range("F" & row)
Doc.getElementById("l_amount").Value = .Range("M" & row)
Doc.getElementById("l_terms").Value = .Range("N" & row)
Doc.getElementById("h_phone").Value = .Range("G" & row)
Doc.getElementById("m_phone").Value = .Range("H" & row)
Doc.getElementById("address1").Value = .Range("J" & row)
Doc.getElementById("town_city").Value = .Range("K" & row)
Doc.getElementById("p_code").Value = .Range("L" & row)
Doc.getElementById("email").Value = .Range("I" & row)
If .Range("O" & row) = "Tenant" Then
Doc.all("owner")(1).Click
Else
Doc.all("owner")(0).Click
End If
If .Range("P" & row) = "Tenant" Then
Doc.all("guarantor")(1).Click
Else
Doc.all("guarantor")(0).Click
End If
Doc.getElementById("contactViaPost").Checked = True
Doc.getElementById("contactViaEmail").Checked = True
Doc.getElementById("contactViaPhone").Checked = True
Doc.getElementById("agreeToTOS").Checked = True
Doc.getElementById("submit_application").Click
Do While appIE.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Waiting ..."
Application.Wait DateAdd("s", 1, Now)
Loop
Application.Wait DateAdd("s", 20, Now)
Set HCollection = appIE.document.getElementsByTagName("h2")
For Each c In HCollection
If c.className = "vc_custom_heading" Then
.Range("Q" & row) = c.innerText
Exit For
End If
Next
然而这一行
.Range("Q" & row) = c.innerText
总是将旧文本返回给我
我尝试增加等待时间,但不是运气。有人可以帮忙吗
【问题讨论】:
标签: vba