Solved

waiting while  webbrowser busy ?

Posted on 2001-07-19
18
1,691 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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
 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DIR issue 7 54
Cannot enter table caption text in Word protected document 6 123
Visual Studio 2005 text editor 10 38
VBA - If Bookmark = "XXBOOKMARKXX" then 15 25
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

785 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