0

I'm trying to write my first website login script but always getting an error in line 9 position 9 saying:

"Object Required: 'getElementByID(...)' 800A01A8.

Here's my code for the real working site:

Call Main

Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "https://www.valuedopinions.com/eng/signin"
Wait IE
With IE.Document
    .getElementByID("tx_voputilities_pi1[email]").value = "my@email.com"
    .getElementByID("tx_voputilities_pi1[password]").value = "mypassword"
    .getElementByID("tx_voputilities_pi1[sign_in]")(0).Submit
End With
End Function

Sub Wait(IE)
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
End Sub

How can I write working code?

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

3

Your login form elements have the name rather than id, so you need to use getElementsByName. Also, INPUT elements don't have the Submit method, use click instead:

With IE.Document
    .getElementsByName("tx_voputilities_pi1[email]")(0).value = "my@email.com"
    .getElementsByName("tx_voputilities_pi1[password]")(0).value = "mypassword"
    .getElementsByName("tx_voputilities_pi1[sign_in]")(0).click
End With
Helen
  • 87,344
  • 17
  • 243
  • 314