Solved

waiting while  webbrowser busy ?

Posted on 2001-07-19
18
1,719 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

749 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