Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE automation query

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
hi,

the below coding is part of an IE automation script.

Code:
If objie Is Nothing Then
    'page isn't open yet
    'create new IE instance
    Set objie = GetNewIE
    'make IE window visible
    With objie
    Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
    .Visible = True
    With .Document.forms("frmLogin")
        .sUserName.Value = "username"
        .sPassword.Value = "password"
        .submit.Click
    End With
    End With
    'load page
    If LoadWebPage(objie, myPageURL) = False Then
      'page wasn't loaded
      MsgBox "Couldn't open page"
      Exit Sub
    End If
  End If

if the coding is run through it doesnt login, if I step through the coding it logs in, I can't understand why it is doing this.

i have put a applicatio wait in front off the submit line and still no difference.

anyone got any ideas why.

Rob.

Hope this is of use, Rob.[yoda]
 
Yes, when you step through your code, the browser has more time to draw everything. You have a timing issue somewhere. I would suggest making a subroutine like this
Code:
Sub wait(byref objie as InternetExplorer)
Do 
Loop Until objie.Busy = False
End Sub

And call it whenever you're supposed to wait for the browser to catch up.

the only problem I've seen with this is when instantiating a browser, it sometimes misses. So, if need be, throw a 1 second Application.Wait in there.
Code:
  newHour = Hour(Now())
  newMinute = Minute(Now())
  newSecond = Second(Now()) + 1
  waitTime = TimeSerial(newHour, newMinute, newSecond)
  Application.wait waitTime
 
have had application wait and busy in and still no difference, it wont go through

Hope this is of use, Rob.[yoda]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top