troubleshooting Question

Error 91 on webbrowser

Avatar of alanvranian
alanvranianFlag for United States of America asked on
Visual Basic Classic
8 Comments1 Solution1276 ViewsLast Modified:
Using VB6 -

I have the webbrowser control on a form, everything is at the defaults except I change the size and make it visible just before I load the html into it.  The html is text that I get from mimeparsing email messages.  I've found the webbrowser control to be highly unreliable where sometimes it gives me an error code 91 - object variable not set when I load the text into it.  I've reviewed other postings on here extensively about this and tried a dozen different ways of loading the text, or looping till the readystate changes, etc etc and I can't get past this.

Oddly, I'll get it working just fine in the VB editor environment, and then when I compile it the exact same test data crashes in the compiled code.

If someone sees the error of my ways, that would be greatly appreciated... I've wasted days on this one issue now.

Here's the code:

(at this point in the routine, I have extracted the html code from the email message and stored it in the strTempHtml variable... then I simply do this)

        WebBrowser1.Left = 0
        WebBrowser1.Width = 10900
        WebBrowser1.Height = 5550
        WebBrowser1.Top = 1590
        WebBrowser1.Visible = True
        WebBrowser1.Document.Open ("")     ' (have also tried "about:blank" here)
        WebBrowser1.Document.Write strTempHtml

...and... thats it...  

This code opens my test email perfectly in the development environment, but as soon as I compile it, the compiled version gives me error 91 on the exact same data at the document.write statement.

I had wondered if maybe the problem was in the html I extracted from the email messages, but that appears to be OK.  I have samples you can download and look st, if you want to, at www.ehvee.com/eesample.zip 

test1.html is the email that loads perfectly in the development environment, but gives me error 91 in the compiled version.  test2.html is code that never downloads the images in the develkopment environment and if I do a loop to give it doevents time, it never completes.  Both give me 91 in compiled.

Both of these load just fine in IE if you do a file open.


In trying to find a way to make this work, I've also tried all the statements below, in a variety of  sequences...

        'WebBrowser1.Navigate "about:blank"

        'WebBrowser1.Document.Open ("about:blank")

        'WebBrowser1.Document.body.innerHTML = strTempHtml
       
        'WebBrowser1.Document.documentElement.innerHTML = strTempHtml
       
        'Do Until WebBrowser1.ReadyState = READYSTATE_COMPLETE
        '    DoEvents
        'Loop

        'While WebBrowser1.ReadyState < 4
        '    DoEvents
        'Wend

        'WebBrowser1.Refresh
       
        'Do Until WebBrowser1.Busy = False
        '    DoEvents
        'Loop

ASKER CERTIFIED SOLUTION
PatG042800

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros