Avatar of alanvranian
alanvranian
Flag for United States of America asked on

Error 91 on webbrowser

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

Visual Basic Classic

Avatar of undefined
Last Comment
alanvranian

8/22/2022 - Mon
PatG042800

I had the same error 91 when I used your code in a project in VB 6.0.

I know you said you tried the navigate method but I was able to get my project to run in design and compiled mode by using the following

change
WebBrowser1.Document.Open ("")
to
WebBrowser1.Navigate ("about:blank")

change
WebBrowser1.Document.Write strTempHtml
to
WebBrowser1.Navigate strTempHtml

Here is the complete code of the project that works on my computer
one form, one web broswer, three command buttons

+++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command1_Click()
        strTempHtml = "C:\temp\test1.html"
        Me.WebBrowser1.Navigate strTempHtml
End Sub

Private Sub Command2_Click()
        strTempHtml = "C:\temp\test2.html"
        Me.WebBrowser1.Navigate strTempHtml
End Sub

Private Sub Command3_Click()
        strTempHtml = "http://www.google.com"
        Me.WebBrowser1.Navigate strTempHtml
End Sub

Private Sub Form_Load()
        Me.WebBrowser1.Left = 10
        Me.WebBrowser1.Width = 5000
        Me.WebBrowser1.Height = 5000
        Me.WebBrowser1.Top = 720
        Me.WebBrowser1.Visible = True
        Me.WebBrowser1.Navigate ("about:blank")
End Sub

+++++++++++++++++++++++++++++++++++++++++++++++++

Now if that does not work tell me, do you have any 3rd party IE toolbars installed on your computer? If so which one(s).
alanvranian

ASKER
Not working for me...  when I use this approach, I get nothing in the browser.  If I add in a refresh afterwards, it says that basically the content cannot be found.  Ordinarily I use Codesmart, so thats a third party toolbar, but at your comment I turned that off and restarted VB and the behavior did not change.

This is some of the inconsistency I've been dealing with... works fine for you, not for me.  May well be my machine or my environment but without more info from the control, how do I know what to change?

Thanks for your effort... you did a lot of work on my behalf.
alanvranian

ASKER
This is a bit more interesting now, however...  when I compile using your programming technique, I get this error: <img src="http://www.ehvee.com/ee1.jpg"> (hoping one can use inline images here), followed by -2147023673 Automation error where the control is basically saying it cannot find the thing I want to load.  Basically, it isn't working using the navigate method when the html is stored in a string.  I suppose I could write the html to a disk file and then open that and clean up afterwards, but thats pretty inefficient.  A possible workaround, however.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
PatG042800

OK, look at Properties for C:\WINDOWS\system32\shdocvw.dll then Version tab \ File Version

I am running version 6.00.2900.2937 (xpsp_sp2_gdr.060623-0002)

Also are you using VB 6?

Did the code fail in design view or only after you compiled?
alanvranian

ASKER
I'll have to wait till I get back to that development machine to give you the dll version... so that won't be till this evening.

Yes, it is VB6.  In design view, there is no error message .... just nothing displays in the control.  The error message I quoted only shows up in the compiled code.

Thanks
alanvranian

ASKER
6.00.2900.2937 (xpsp_sp2_gdr.060623-0002)

I'm running the exact same version of shdocvw.dll as you...
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
PatG042800

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
alanvranian

ASKER
Yea, about half the time I wind up posting a question on here, it has no answer because I'm pretty thorough in troubleshooting before I resort to bothering other people.  If I'm here, its sort of a last resort...

I did test the compiled code on other machines in my lab... and the problem follows the code across a variety of versions of Windows and processors....

I haven't played with windbg, I'll do that... sounds like fun and who knows, maybe it will br the "Voila" moment...

Meanwhile, I've gone ahead and done an inelegant workaround where I'm writing the html to a temporary disk file, opening that in the browser and then killing the file when the form closes.  Its slower, but at least it works.  My quest for a better webbrowser control than microsofts also continues..

Thanks for your effort on this.. enjoy the points :)
Alan