Why is my VBScript not logging in properly? This .vbs script should open reddit
ID: 3909509 • Letter: W
Question
Why is my VBScript not logging in properly?
This .vbs script should open reddit and automatically login. Instead I get an error stating I need an object? (The username and password fields are not an actual account).
Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.navigate("https://old.reddit.com")
objIE.Visible = True
Do Until objIE.ReadyState = 4 : Call WScript.Sleep(100) : Loop
With objIE.Document
.getElementByID("user").value = "username"
.getElementByID("passwd").value = "mypass"
.getElementByID("submit").submit
End With
Explanation / Answer
Kindly use the below given script
Function Main
Set objIE = WScript.CreateObject("InternetExplorer.Application", "IE_")
objIE.Visible = True
objIE.Navigate "https://old.reddit.com"
Wait objIE
With objIE.Document
.getElementByID("user").value = "myusername"
.getElementByID("passwd").value = "mypassword"
.getElementsByName("frmLogin")(0).Submit
End With
End Function
Sub Wait(objIE)
Do
WScript.Sleep 200
Loop While objIE.ReadyState < 4 And objIE.Busy
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.