Hi! I have edited your code a little bit. It now looks like:
Code:
Sub OpenMyWebPage()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.Navigate "https://www.myWebPage.com/default.asp"
'Check for good connection to web page loop!
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop
'Wait for window to open!
Application.Wait (Now + TimeValue("0:00:02"))
'MsgBox "Done"
IE.Visible = True
'Send log-on information!
SendKeys "myUserName", True
SendKeys "{TAB}", True
SendKeys "myPassword", True
SendKeys "{ENTER}", True
End Sub
Here is my NEW problem. When I execute the above code, sometimes it works and sometimes it doesn't work. What do I mean by this?
For the times that it 'doesn't work', I have determined that:
1. the user name field on the web page is already populated
2. the above code 'sees' that the user name field is already populated
3. the code 'skips' the user name field and attempts to put the user name in the password field
4. an error on the webpage occurs because I'm trying to pass an incorrect password
When does this happen? It seems to happen if I DO NOT delete temporary internet files and/or 'clear forms' or 'clear passwords' (Tools | Internet Options | Content | Auto Complete)
But, it is not feasible for me to delete temp internet files and/or clear forms and clear passwords each time I want to run this macro.
Is there a way that we can edit the above code so that it:
1. Checks to see if the user name field on the webpage is populated
2. If the user name field is popluated, then
3. Proceeds directly to the password field and populates the password field with the password
Basically, we are just adding a check to see if the password field is already populated.
Is this possible?
Thank you so much!
Rachel
