Solved

waiting while  webbrowser busy ?

Posted on 2001-07-19
18
1,671 Views
Last Modified: 2007-11-27
hi,

another question....

I have a prog that submit a form then once submitted it load a welcome page, at this way I want to go back.

I use this :

[submitting form.....]
 Do
  DoEvents
 Loop Until Not WebBrowser1.Busy
WebBrowser1.GoBack

it give me an error :

method error, goback failed....

I think the function don't wait enough until the page is fully loaded...

is there any sure way to wait until the page be fully loaded ?

Regards,

Oliver
0
Comment
Question by:albundy
  • 6
  • 3
  • 2
  • +6
18 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6298828
Isn't there a NavigateComplete property?
0
 
LVL 4

Expert Comment

by:nutwiss
ID: 6298840
yup...
0
 
LVL 4

Expert Comment

by:nutwiss
ID: 6298846
try:

Do While WebBrowser1.NavigateComplete = false
    DoEvents
Loop
0
 

Author Comment

by:albundy
ID: 6298857
don't work...

it didn't recognize this function :(
0
 

Author Comment

by:albundy
ID: 6298864
Isn't there a NavigateComplete property?

yep there is but didn't work too.... it doesn't wait the full load of the page
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6298926
You should use the Document_Complete event

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
  If URL = "Your Target URL" Then WebBrowser1.GoBack
End Sub

You don't need to use a loop or anything this way.
0
 

Author Comment

by:albundy
ID: 6298960
already tryed it... don't work too.... :(

is there any way to tell vb to wait 1 second or more ?
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6299110
Use this in your code

 
Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Vin.
0
 

Author Comment

by:albundy
ID: 6299175
doesn't seems to work too :(

does sleep do events ? or does it stop all process ?

anyway it is not a good solution I think....

if anyone have a working code....pleaze :)
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 28

Expert Comment

by:AzraSound
ID: 6299198
TimCottee's solution should work.  but go ahead and try:

Do While WebBrowser.ReadyState <> READYSTATE_COMPLETE
   DoEvents
Loop

and just put an On Error Resume Next statement in the sub calling the GoBack method...the error being thrown may not even affect the operation.
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6301359
How many MilliSeconds did you wait for.

Sleep just waits for the specified number of milliseconds before returning.

Vin.
0
 

Author Comment

by:albundy
ID: 6301597
sleep stop processing and that's not what I want

any way azrasound function give me an error with doc.form...

I used my previous version

Do
 DoEvents
Loop Until Not WebBrowser1.Busy

seems to be good enough.... I puted a timer, that seems to be the best.... but of course bug sometime :(

thx anyway...
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6302058
doc.form??
0
 

Author Comment

by:albundy
ID: 6302078
yup, I use it to submit data to a form...
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6302409
well that should not be related to anything i posted, but oh well, looks like you found your best solution.  good luck to you.
0
 

Expert Comment

by:viklele
ID: 6304282
Try this :

----------------------------------------------------
Dim bBackEnabled as Boolean

'for loading a page
Sub LoadPage(ByVal sURL As String)
   WebBrowser1.Navigate sURL

   Do
      'putting additional DoEvents ... don't bother
      'WebBrowser control too frequently
      DoEvents
      DoEvents
      DoEvents
   Loop Until Not WebBrowser1.Busy

End Sub

'for going back
Sub GoBack()
   Do
      DoEvents
      DoEvents
      DoEvents
   Loop Until Not bBackEnabled
   WebBrowser1.GoBack
End Sub

'for keeping track of the back button state
Private Sub WebBrowser1_CommandStateChange _
(ByVal Command As Long, ByVal bEnable As Boolean)

   If (Command = 2) Then 'back button
      bBackEnabled = bEnable
   End If

End Sub

----------------------------------------------------
Let me know if this solved your problem.

- Vikram
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7156226
Hi albundy,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

albundy, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 7182280
Placed in PAQ

Computer101
E-E Moderator
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now