履带式和履带式刮刀使用excel vba

时间:2018-03-22 08:21:32

标签: excel vba excel-vba

我正在尝试在Intranet URL中抓取,因此我可以让excel自动从下拉菜单中选择一个选项,然后在文本框中输入一个值,然后单击Find以重定向到另一个页面,我想在同一个工作簿中获取一个值副本到另一个工作表,我创建了下面的代码,但代码不起作用,说需要对象。 :(

Sub Test()

    Dim rng As Range
    Set rng = Sheets("sheet1").Range("A1", Sheets("sheet1").Cells.Range("A1").End(xlDown))

        Set ie = CreateObject("InternetExplorer.application")
        ie.Visible = True
        ie.Navigate ("https://gcd.ad.plc.cwintra.com/GCD_live/login/login.asp")
        Do
            If ie.ReadyState = 4 Then
                ie.Visible = False
                Exit Do
            Else
                DoEvents
            End If
        Loop

        ie.Document.forms(0).all("txtUsername").Value = ""
        ie.Document.forms(0).all("txtPassword").Value = ""
        ie.Document.forms(0).submit
        ie.Visible = True

        Appliction.Wait (Now + TimeValue("00:00:02"))

        DoEvents

    For Each cell In rng

        ie.Navigate ("https://gcd.ad.plc.cwintra.com/GCD_live/search.asp")

        DoEvents

        ie.Document.getElementById("cboFieldName").selectedIndex = 6
        ie.Document.getElementById("txtFieldValue").Select
        SendKeys (cell.Value)

        DoEvents

        ie.Document.getElementById("cmdFind").Click

    Next cell

End Sub

0 个答案:

没有答案