Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA Web刮片-需要对象错误_Vba_Excel_Web Scraping - Fatal编程技术网

Excel VBA Web刮片-需要对象错误

Excel VBA Web刮片-需要对象错误,vba,excel,web-scraping,Vba,Excel,Web Scraping,我有一小段代码,试图在网站上搜索,并告诉是否有任何结果 这对我(@India)很有好处,但对我的同事(@US)却没有好处。他检查了他的两台电脑,但发现了同样的错误 单击“搜索”按钮后,ie.Document变为完全空白,ie.Document.ChildNodes.Length返回0。 Sub iTest() Call ProcessRecord("First_Name", "Middle_Name", "Last_Name", "1/1/2015") End Sub Private F

我有一小段代码,试图在网站上搜索,并告诉是否有任何结果

这对我(@India)很有好处,但对我的同事(@US)却没有好处。他检查了他的两台电脑,但发现了同样的错误

单击“搜索”按钮后,ie.Document变为完全空白,ie.Document.ChildNodes.Length返回0。

Sub iTest()
    Call ProcessRecord("First_Name", "Middle_Name", "Last_Name", "1/1/2015")
End Sub
Private Function ProcessRecord(fName As String, mName As String, lName As String, dob As String) As Boolean
    Dim results As String, idx%

    Dim ie As New InternetExplorer
    ie.Visible = True

    Navigate ie, "http://ws.ocsd.org/ArrestWarrants/default.aspx"
    Do While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE
        Application.Wait Now + TimeSerial(0, 0, 1)
    Loop
    Do While ie.Busy Or ie.Document.ReadyState <> "complete"
        Application.Wait Now + TimeSerial(0, 0, 1)
    Loop

    ' fill values in webpage
    ie.Document.getElementById("FirstName").Value = fName
    ie.Document.getElementById("MiddleName").Value = mName
    ie.Document.getElementById("LastName").Value = lName
    ie.Document.getElementById("DOB").Value = dob

    ' click on search button
    ie.Document.getElementById("btnSearch").Click

    ' wait for results
    Do While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE
        Application.Wait Now + TimeSerial(0, 0, 1)
    Loop
    Do While ie.Busy Or ie.Document.ReadyState <> "complete"
        Application.Wait Now + TimeSerial(0, 0, 1)
    Loop

    ' check results
    results = ie.Document.getElementById("lblResults").innerText            '<< It gives Object Required error here. Because ie.Document has no element after I click on search button.

    If results = "No Results Found." Then
        MsgBox "Not found", vbExclamation
    Else
        MsgBox "Found", vbExclamation
    End If

    ie.Quit
End Function
Sub-iTest()
呼叫过程记录(“名字”、“中间名”、“姓氏”、“2015年1月1日”)
端接头
私有函数ProcessRecord(fName作为字符串,mName作为字符串,lName作为字符串,dob作为字符串)作为布尔值
将结果变暗为字符串,idx%
Dim ie成为新的InternetExplorer
可见=真实
导航到ie,“http://ws.ocsd.org/ArrestWarrants/default.aspx"
在ie忙或ie ReadyState ReadyState\u完成时执行
应用程序。立即等待+时间序列(0,0,1)
环
在ie.Busy或ie.Document.ReadyState“完成”时执行
应用程序。立即等待+时间序列(0,0,1)
环
'在网页中填充值
ie.Document.getElementById(“FirstName”).Value=fName
ie.Document.getElementById(“MiddleName”).Value=mName
ie.Document.getElementById(“LastName”).Value=lName
ie.Document.getElementById(“DOB”).Value=DOB
'单击搜索按钮
ie.Document.getElementById(“BTN搜索”)。单击
"等待结果"
在ie忙或ie ReadyState ReadyState\u完成时执行
应用程序。立即等待+时间序列(0,0,1)
环
在ie.Busy或ie.Document.ReadyState“完成”时执行
应用程序。立即等待+时间序列(0,0,1)
环
"检查结果,

results=ie.Document.getElementById(“lblResults”).innerText'您尝试过以下方法吗

在ie.Busy或ie.ReadyState ReadyState\u完成时执行
多芬特
循环


似乎对我有效,可能只是您的美国朋友的internet连接延迟。

我的代码中已经有此循环。你有我没有的东西。有什么区别吗?有人来帮忙吗?