Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote