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

Wait for a webpage to load before calling another. 1

Status
Not open for further replies.

jmcg

Technical User
Jun 30, 2000
223
GB
Been trying to set up a form that will call a webpage, wait for it to load and then call another page. The pages can take 10-15 mins to load.
From other posts I have tried
Code:
Set IE = Me.WebBrowser
IE.Navigate "[URL unfurl="true"]http://www.google.co.uk"[/URL]
While IE.Busy
'Do nothing
Wend
While IE.Document.ReadyState <> "Complete"
'Do nothing
Wend
IE.Navigate "[URL unfurl="true"]http://www.yahoo.co.uk"[/URL]
While IE.Busy
'Do nothing
Wend
While IE.Document.ReadyState <> "Complete"
'Do nothing
Wend
This seems to go on a perpetual loop as it runs for ages with nothing showing.

Any ideas where I am going wrong.
 
While IE.Document.ReadyState <> [!]4[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV but that doesn't seem to make any difference.

Not sure if relevant but it is called when the Form opens.
 
What about this ?
Code:
On Error GoTo 0
Set IE = Me.WebBrowser
IE.Navigate "[URL unfurl="true"]http://www.google.co.uk"[/URL]
While IE.Busy
  DoEvents
Wend
While IE.ReadyState <> 4
  DoEvents
Wend
IE.Navigate "[URL unfurl="true"]http://www.yahoo.co.uk"[/URL]
While IE.Busy
  DoEvents
Wend
While IE.ReadyState <> 4
  DoEvents
Wend

BTW, I'd use the Load event instead of Open.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for hanging in there on this.
Changed to the above code and to a Load Event and it did not work
However when I changed the 4 back to "Complete" it did work!
Code:
Private Sub Form_Load() 

On Error GoTo 0 
Set IE = Me.WebBrowser2 
IE.Navigate "[URL unfurl="true"]http://www.google.co.uk"[/URL] 
While IE.Busy 
    DoEvents 
Wend 
While IE.Document.ReadyState <> "Complete" 
    DoEvents 
Wend 
IE.Navigate "[URL unfurl="true"]http://www.yahoo.co.uk"[/URL] 
While IE.Busy 
    DoEvents 
Wend 
While IE.Document.ReadyState <> "Complete" 
    DoEvents 
Wend 
End Sub
Thanks again
 
Sorry, my code was for the InternetExplorer.Application object, not the WebBrowser control :~/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top