Results 1 to 4 of 4

Thread: webbrowser control error

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    4
    Hi,

    I am getting an error on the last line it gives a runtime error "91" with the message object variable or with block variable not set. I get this with just a form and the webbrowser control. And following code at form load:

    WebBrowser1.Navigate2 "about:blank"
    Dim strHTML As String
    strHTML = "Your HMTL Code Here"
    WebBrowser1.Document.Body.Innerhtml = strHTML

    This happends on 2 different computers one with nt4 and the other with win2000. Vb version is 6. One with sp3 and the other with no sp. Both using internet explorer 5.

    Would be great if somebody would have an answer to this.
    Greatone

  2. #2
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi,
    Whats happening is that your code is trying to write to the document before it has actually loaded. Try putting the following code in to make sure it is loaded before you write to it:

    [code]
    Private Sub form_load()
    WebBrowser1.Navigate2 "about:blank"
    Dim strHTML As String
    strHTML = "Your HMTL Code Here"
    Do Until WebBrowser1.ReadyState = READYSTATE_COMPLETE
    DoEvents
    Loop
    WebBrowser1.Document.Body.innerhtml = strHTML
    End Sub

    Hope this helps

    Shaun

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Or you can just move the code (that you have after the call to Navigate2 method) to the NavigateComplete2 event.

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    4

    Talking Thanks

    Hi S@NSIS,

    It works!

    Thank you very much. I got the code from an other place. It was in a tutorial even without your line in it. This works great!

    Greetings
    Greatone

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