在JavaScript网页中使用Excel VBA输入数据

时间:2018-07-24 07:24:46

标签: javascript html vba excel-vba

我正在尝试使用excel VBA与HTML网页进行交互。 这是我的代码:

Dim IE As New InternetExplorer
    Dim IEDoc As HTMLDocument
    Dim IE_test As New InternetExplorer

    IE_test.navigate "https://cvatrading.cvaspa.it/irj/portal/anonymous/login"
    IE_test.Visible = True
    'IE_test.Width = 500
    'IE_test.Height = 500

        Application.Wait Time + TimeSerial(0, 0, 3)

        IE_test.document.getElementById("logonuidfield").Value = "userXXX"
        IE_test.document.getElementById("logonpassfield").Value = "passwordXXX"

        Application.Wait Time + TimeSerial(0, 0, 1)

        With IE_test.document
            Set elems = .getElementsByTagName("input")
            For Each e In elems
                If (e.getAttribute("value") = "Eseguire logon") Then
                    e.Click
                    Exit For
                End If
            Next e
        End With

        Application.Wait Time + TimeSerial(0, 0, 3)

        With IE_test.document
            Set elems = .getElementsByTagName("a")
            For Each e In elems
                If e.innerText = "Report" Then
                    e.Click
                    Exit For
                End If
            Next e
        End With

        Application.Wait Time + TimeSerial(0, 0, 3)

        With IE_test.document
            Set elems = .getElementsByTagName("a")
            For Each e In elems
                If e.innerText = "Curve di Carico" Then
                    e.Click
                    Exit For
                End If
            Next e
        End With

        Application.Wait Time + TimeSerial(0, 0, 3)

        ' Javascript?
        IE_test.document.getElementById("aaaa.ReadCurveDiCaricoView.InputFieldPOD").Value = "XXX"

代码可以使用到最后一行

IE_test.document.getElementById("aaaa.ReadCurveDiCaricoView.InputFieldPOD").Value = "XXX"

我认为是JavaScript形式或类似形式,实际上,如果我保存该网页,则找不到该行...(对不起,但这是我第一次使用VBA-HTML)。

https://imageshack.com/a/img923/2826/LvH6RO.jpg

我该如何以这种形式放置一些数据? 非常感谢。

0 个答案:

没有答案