I am writing a VB6 project which uses the InternetExplorer.Application object to log into a website. The login form is a modal ASP form.
All the elements of .Document are from the parent page. How do I get access to the elements on the modal login form which is opened when I do a .Click on the log-in button?
This is my code:
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "http://www.guestlink.co.uk"
IE.Visible = True
Do
DoEvents
Loop Until IE.ReadyState = READYSTATE_COMPLETE
IE.Document.All.Item("ctl00_imgLogin").Click
Do
DoEvents
Loop Until IE.ReadyState = READYSTATE_COMPLETE
With IE.Document.aspnetForm
.getElementById("ctl00_content_txtUserName").Value = "MyName"
....
End With
VB gives “object variable not set” error because IE.Document.aspnetForm points to an element on the parent page, not the modal ASP form. How do I get .document to point to the modal form?
The URL you are using is for the main page, but the log in form is inside an IFRAME. Try changing the URL (IE.navigate) to:
https://www.guestlink.co.uk/login.aspx?placeValuesBefore