Link to home
Start Free TrialLog in
Avatar of tolvor
tolvor

asked on

Visual Basic SHDocVw.InternetExplorer IsBusy is always true, object not updating

Short version:
I have a SHDocVw.InternetExplorer object that after Navigate is called does not finish loading. This browser control IsBusy = true, and ReadyState=1 despite the page in Internet Explorer can be visually seen as having finished loading. I've tried calling oIE.Refresh, but Visual Basic throws an exception (HRESULT E_FAIL has been returned from a call to a COM component). How can I get the object to show the updated webpage?


Long version:
I have a project that invokes a dynamic internet explorer object (the project does not allow having an in-application WebBrowser control). This is called by Dim oIE As SHDocVw.InternetExplorer.

There are 2 calls to oIE.Navigate. The first one works perfectly. On calling the second page the page does not load as previously described. Checking the oIE object in Debug mode shows that after calling the second Navigate, the oIE.URL is still set to the first pages URL, not the second.

If the following code is added (below) (after 2nd navigate) an infinite loop results.
Do While oIE.busy Or oIE.ReadyState <> 4
  System.Windows.Forms.Application.DoEvents()
Loop

Here is the interesting part. If in debug mode, an execution breakpoint is placed immediately before the 2nd navigate command, run the program, and natually execution pauses. If the program is resumed doing with no other changes, the 2nd navigate works correctly.

Naturally that suggests giving the program a timeout. However using timers to pause execution, as well as using Sleep(), but neither works. Tried multiple calls to DoEvents (with more timeouts) before 2nd Navigate but that doesn't work either.

Is there a solution to making the second Navigate load the page correctly?
ASKER CERTIFIED SOLUTION
Avatar of vb_elmar
vb_elmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tolvor
tolvor

ASKER

VBA.Interaction.DoEvents, as well as DoEvents are not valid subs in my VB2013.
I've reducted the code for another ajax site that exhibits the same problem. The main site that I want to test requires a login that making setting up test code difficult.

Execution on this code never finishes, and gets caught in an infinite loop.

Any help would be appreciated.

Thanks

====================================================================
   Dim oIE As SHDocVw.InternetExplorer

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        oIE = CreateObject("InternetExplorer.Application")
        oIE.Visible = True
        oIE.Navigate("http://www.happybidday.com/index.php")   ' https://us.etrade.com/home   

        Do While oIE.Busy Or oIE.ReadyState <> 4
            System.Windows.Forms.Application.DoEvents()
        Loop

        oIE.Navigate("http://www.happybidday.com/viewproduct.php?aid=269495")
        'Do While oIE.Busy Or oIE.ReadyState <> 4
        'System.Windows.Forms.Application.DoEvents()
        'Loop
        Label1.Text = "successful"
    End Sub