简体   繁体   中英

Excel VBA automate data entry in a web

 Sub Godmode()

    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")

    IE.Visible = True
    IE.navigate "http://charterweb.santanderuk.gs.corp/CharterServiceChain/default.aspx"

    Do While IE.Busy
        Application.Wait DateAdd("s", 1, Now)
    Loop

    IE.document.getElementById("M_E_ctlPartField208_V").Value = "test"


End Sub

I am always getting an error saying; method document of object iwebbrowser2 failed

You need to get the element ID, then as a second command assign a value to that element.


elementIwantToChange = IE.document.getElementById("M_E_ctlPartField208_V")

elementIwantToChange.Value = "test"

Also you should test whether the element ID returned is "null"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM