Results 1 to 4 of 4

Thread: Webbrowser ReadyState

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Resolved Webbrowser ReadyState

    I enter a stock code I want the price for in a hidden webbrowser control and then simulate clicking the submit button using the below code. The problem is the page hasn't finished loading by the time I get the source code of the page.

    I thought the loop I've got would have worked but it doesn't?? Are there any other ways to "do nothing" until a page has finished displaying all text/images etc...??

    VB Code:
    1. WB1.Document.All("SecurityCode").Value = QuoteInfo(1, i) 'share code
    2. WB1.Document.getElementById("btnAction").Click 'submit form
    3.  
    4. 'while page is loading do nothing
    5. Do While WB1.ReadyState <> READYSTATE_COMPLETE
    6. DoEvents
    7. Loop
    8.  
    9. 'Get html source
    10. SourceCode = WB1.Document.documentElement.OuterHTML
    Last edited by lintz; Dec 17th, 2005 at 06:53 AM.

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Webbrowser ReadyState

    Quote Originally Posted by lintz
    Are there any other ways to "do nothing" until a page has finished displaying all text/images etc...??
    Something like this ?
    VB Code:
    1. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2.  
    3.     If pDisp Is WebBrowser1.Object Then
    4.         Debug.Print "Finished Loading"
    5.         ' Do your job
    6.     Else
    7.         ' Do nothing
    8.     End If
    9.  
    10. End Sub
    Last edited by iPrank; Feb 22nd, 2007 at 04:25 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Webbrowser ReadyState

    Thanks Prank, added some further code and does what I'm after

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Webbrowser ReadyState

    Glad to help
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width