I am new to excel vba macro. I am trying to login to a website using the below code, which gives me Runtime error 91"object variable not set".
please help
i am pasting code below
it is giving me error @ UserNameIp.Value = "xxxxxxx(username)"
Code
Sub browserlogin()
Dim ieDoc As MSHTML.HTMLDocument
Dim MyBrowser As SHDocVw.InternetExplorer
Dim UserNameIp As MSHTML.HTMLInputElement
Dim Password As MSHTML.HTMLInputElement
Dim NextButton As MSHTML.HTMLInputElement
Dim SignInButton As MSHTML.HTMLInputElement
Dim KeepMeLoggedInCheckBox As MSHTML.HTMLInputElement
Dim MyURL As String
MyURL = "(URL HERE)"
Set MyBrowser = New SHDocVw.InternetExplorer 'Create INternet Explorer Object
MyBrowser.navigate MyURL ' Navigate to URL
Do Until MyBrowser.readyState = READYSTATE_COMPLETE: Loop 'wait for page to load
Set ieDoc = MyBrowser.document ' get document object
MyBrowser.Visible = True
Application.Wait Now() + #12:00:02 AM#
Set UserNameIp = ieDoc.all.Item("userInput")
Set NextButton = ieDoc.all.Item("login-button")
UserNameIp.Value = "xxxxxxx(username)"
Application.Wait Now() + #12:00:02 AM#
NextButton.Click
Application.Wait Now() + #12:00:02 AM#
Set Password = ieDoc.all.Item("passwordInput")
Password.Value = "xxxxx(password)"
Application.Wait Now() + #12:00:02 AM#
Set SignInButton = ieDoc.all.Item("login-button")
Application.Wait Now() + #12:00:02 AM#
SignInButton.Click
End Sub
Display More