I'm using the following code to login to a web page.
Code: Select all
Sub login()
Const Url$ = "https://abc.com/"
Dim UserName As String, Password As String, LoginData As Worksheet
Set LoginData = ThisWorkbook.Worksheets("Sheet3")
UserName = LoginData.Cells(1, "B").Value
Password = LoginData.Cells(2, "B").Value
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
With ie
.navigate Url
ieBusy ie
.Visible = True
Dim oLogin As Object, oPassword As Object
Set oLogin = .Document.getElementsByName("id")(0)
Set oPassword = .Document.getElementsByName("password")(0)
oLogin.Value = UserName
oPassword.Value = Password
.Document.forms(0).submit
End With
End Sub
Sub ieBusy(ie As Object)
Do While ie.Busy Or ie.readyState < 4
DoEvents
Loop
End Sub
Object variable or with block variable not set highlighting the line oLogin.Value = UserName
How can I overcome this? any help on this would be kindly appreciated. Thanks in advance.