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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application.Wait problem

Status
Not open for further replies.

Eoll

Technical User
Feb 5, 2005
7
NO
Thanks to the great threads on this forum, this is only the second time i've come to dead end and need help.
All the other times i've able to adapt a bit of code here and there to suit my needs....

here's my problem. What I've been doing is automating a couple of functions run from excel to get data from the internet etc.
in order to do this i use sendkeys a lot. Not the most gracefull solution i agree, but it works for now.
Every time you push a button on the web however, you get a slight delay, while the next page loads. This delay messes up your next couple of sendkeys.
so I've using this:

Application.Wait (Now + TimeValue("0:00:2"))
works great!


on most pc's. We are on terminal servers here and some are normal desktop pcs setup as terminal clients, while others are small, slick looking.... and dont do my code...
any tips, workarounds?
tried this to no avail somehow:

Do Until oIE.readyState = READYSTATE_COMPLETE
DoEvents
Loop

thanks anyway for reading all the way to the bottom of this post, even if you don't reply...
stijn
 
Hi stijn,
this might sounds stupid but I thought I would make sure. Are you specifying the wait on your sendkeys?

Jay
 
Hi jay, thanks for taking a look.
The part of the code i'm refering to looks like this:
SendKeys "{tab 2}"
SendKeys sUsername
SendKeys webTab
SendKeys sPassword
SendKeys "{ENTER}"
Application.Wait (Now + TimeValue("0:00:2"))
SendKeys "{tab 3}"
SendKeys "{ENTER}"
Application.Wait (Now + TimeValue("0:00:2"))
SendKeys "{tab 20}"
SendKeys "{ENTER}"
Application.Wait (Now + TimeValue("0:00:2"))
SendKeys "{tab 24}"

as you can see, lots of application.waits when shifting from webpage to webpage. Tried to take a look at the html code so that i could use the html id tags to navigate (lot safer) but it seems the part of the site i'm trying to access is a java applet or something... anyway no html code to retrieve.
regards stijn
 
You can use browser events to trap its state. The reference library name: SHDocVw, file: shdocvw.dll.
More in MSDN:
Sample code:
Code:
 clsBrowser class module:

Public WithEvents IE As SHDocVw.InternetExplorer

Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
MsgBox "Completed"
End Sub


 standard module:
Dim IE As SHDocVw.InternetExplorer
Dim wb As clsBrowser

Sub OpenSource()
Set IE = New SHDocVw.InternetExplorer
Set wb = New clsBrowser
Set wb.IE = IE
IE.Visible = True
IE.Navigate URL:="[URL unfurl="true"]http://www.tek-tips.com"[/URL]
End Sub

combo
 
Thanks to both jay and combo for taking a look.
I've been trying my way with the browser states to get it to work, but to no avail.
Combo, could you take a look at my code and give a proposition on how to work the browser state into it?
tried it with a
do until document loaded loop
thingy but didnt get it to work....
thanks

stijn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top