jeremypyle
Board Regular
- Joined
- May 30, 2011
- Messages
- 174
Hi
I am trying to login to Home
This is my code so far. Please note, username and password is only example. I have worked out how to get it to fill in the username and password I think. But not sure how to make it click the button
I think the error with my code is:
Set Button = .getElementsByClassName("btn btn-primary button-shadow login-button")
But I'm not exactly sure how to fix this
Sub FollowWebsiteLink()
Dim ie As Object
Dim htmldoc As HTMLDocument
Dim UserName As String, Password As String
UserName = "jeremy"
Password = "asdf1234"
Application.ScreenUpdating = False
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "Home"
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Loading website..."
DoEvents
Loop
newwebsite = (ie.document.getElementsByClassName("my-ir hidden-xs btn btn-green myir-popup__desktop-trigger"))
Set htmldoc = ie.document
ie.navigate newwebsite
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Loading website..."
DoEvents
Loop
With htmldoc
Dim oLogin As Object, oPassword As Object
Set oLogin = .getElementsByTagName("input")(1)
Set oPassword = .getElementsByTagName("input")(2)
Set Button = .getElementsByClassName("btn btn-primary button-shadow login-button")
oLogin.Value = UserName
oPassword.Value = Password
Button.Click
End Sub
I am trying to login to Home
This is my code so far. Please note, username and password is only example. I have worked out how to get it to fill in the username and password I think. But not sure how to make it click the button
I think the error with my code is:
Set Button = .getElementsByClassName("btn btn-primary button-shadow login-button")
But I'm not exactly sure how to fix this
Sub FollowWebsiteLink()
Dim ie As Object
Dim htmldoc As HTMLDocument
Dim UserName As String, Password As String
UserName = "jeremy"
Password = "asdf1234"
Application.ScreenUpdating = False
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "Home"
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Loading website..."
DoEvents
Loop
newwebsite = (ie.document.getElementsByClassName("my-ir hidden-xs btn btn-green myir-popup__desktop-trigger"))
Set htmldoc = ie.document
ie.navigate newwebsite
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Loading website..."
DoEvents
Loop
With htmldoc
Dim oLogin As Object, oPassword As Object
Set oLogin = .getElementsByTagName("input")(1)
Set oPassword = .getElementsByTagName("input")(2)
Set Button = .getElementsByClassName("btn btn-primary button-shadow login-button")
oLogin.Value = UserName
oPassword.Value = Password
Button.Click
End Sub