Hello,
I am having trouble finding code that will work with this website.
I found the following code but it keeps opening the website and giving me the following error message: "Object variable or With block variable not set"
can any one help me? I would also perfer to use chrome instead of IE if possible.
Thanks,
Sub LoginToURL()
Dim ie As Object, iebody As String, strURL As String, strUsername As String, strPassword As String
Set ie = CreateObject("InternetExplorer.Application")
strURL = "http://www.costar.com/"
strUsername = "Username here"
strPassword = "password here"
ie.Navigate strURL
'Wait until page is loaded.
While ie.ReadyState < 4 ' READYSTATE_COMPLETE = 4
DoEvents
Wend
ie.Visible = True
ie.Document.All("username").Value = strUsername
ie.Document.All("password").Value = strPassword
ie.Document.All("sign-in-button").Click
'Wait until page is loaded.
While ie.ReadyState < 4 ' READYSTATE_COMPLETE = 4
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:05"))
iebody = ie.Document.body.innerhtml
If InStr(iebody, "The information you entered is invalid.") <> 0 Then
MsgBox "Login failed!", vbCritical + vbOKOnly
Else
MsgBox "Login successful!", vbInformation + vbOKOnly
End If
ie.Quit
Set ie = Nothing
End Sub
Bookmarks