1

这是我的代码,不幸的是,公司问题我无法发布真正的网址,它可以工作但不是我想要的方式,请查看下面的问题:

Dim doc As HTMLDocument
Dim IE As InternetExplorer
Dim TDelements As IHTMLElementCollection
Dim TDelement As HTMLTableCell
Dim r As Long

Sub ficfinder()
Set IE = CreateObject("InternetExplorer.Application")
    With IE
        .Visible = True
        .navigate URL:="...INPUT"<---this is my search form, but i have to redact due to co policy
    Do 'Until .readyState = 4
    DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE
    'pick field to fill out
    Set mytextfield1 = .document.all.Item("WESTAC")
    'set value to put in
    mytextfield1.Value = "5416869160"
    'click the submit button
    IE.document.all.Item("Submit").Click
    Do 'Until .readyState = 4
    DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE
    End With
'I think i'm missing something here

    Set doc = IE.document
    Dim sdd As String
    Set TDelements = doc.getElementsByTagName("td")
    r = 0
    For Each TDelement In TDelements
        If TDelement.Align = "right" Then
            Sheet2.Range("A1").Offset(r, 0).Value = TDelement.innerText
            r = r + 1
        End If
    Next
End Sub

所以这可以工作并将数据放入我的电子表格中,但它提取的数据来自搜索表单,而不是您提交后出现的页面。我如何使 IE.document 出现的新页面?

任何帮助表示赞赏,谢谢!

4

1 回答 1

0

我添加了

Do While IE.Busy: DoEvents: Loop

就在提交之后,它工作得很好。感谢蒂姆威廉姆斯的帮助!

于 2013-03-09T03:33:53.317 回答