Microsoft Web Browser

M

Murp

Bit stumped by this control. I am using it to display HTML stored in a table
on a form. The OnCurrent event procedure on the form is:

Me.ocxWebBrwsr.Object.Document.body.innerHTML = "<HTML><HEAD></HEAD><BODY>"
& _
"<FONT size=-1>" & [DescWeb] & strAuth & strDetail & "</font> </body>"

When I open the form, I get the following error:
"Run-time error 91: Object variable or With block variable not set"

If I click "End", the form opens, but there is nothing in the control. BUT
every subsequent record I go to works fine from that point on.

Any help would be much appreciated.
 
R

Ron Weiner

Yo Yo Ma

The Microsoft Web Browser control needs to be initalized by browsing to
"about:blank" before you go to use it for the first time. I recommend that
in the Foem_Load event yo add some code like:

Define this constant somewhere in the General section of the forms code

Const NAV_NO_HISTORY = &H2

Then in the Foem_Load() event add this

' Initalize Browser control by navigating to nowhere
wbMain.Navigate "about:blank", NAV_NO_HISTORY

Once that is done I have found that I am able to manulipate the control and
all of its properties without error.

Ron W
www.WorksRite.com

Murp said:
Bit stumped by this control. I am using it to display HTML stored in a table
on a form. The OnCurrent event procedure on the form is:

Me.ocxWebBrwsr.Object.Document.body.innerHTML =
& _
"<FONT size=-1>" & [DescWeb] & strAuth & strDetail & "</font> </body>"

When I open the form, I get the following error:
"Run-time error 91: Object variable or With block variable not set"

If I click "End", the form opens, but there is nothing in the control. BUT
every subsequent record I go to works fine from that point on.

Any help would be much appreciated.
 
S

Siggi Bjarnason

OK I've got a similar issue. Here is snipped from my code:
Form_DiaryError.txtError.Value = oPoster.responseText
Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Object.Document.body.innerHTML =
oPoster.responseText

First of I periodically get the object not set error below, but never when I
step through the code. When the code executes without an error the browser is
always blank even though the text box contains the HTML code.

Any ideas?

Ron Weiner said:
Yo Yo Ma

The Microsoft Web Browser control needs to be initalized by browsing to
"about:blank" before you go to use it for the first time. I recommend that
in the Foem_Load event yo add some code like:

Define this constant somewhere in the General section of the forms code

Const NAV_NO_HISTORY = &H2

Then in the Foem_Load() event add this

' Initalize Browser control by navigating to nowhere
wbMain.Navigate "about:blank", NAV_NO_HISTORY

Once that is done I have found that I am able to manulipate the control and
all of its properties without error.

Ron W
www.WorksRite.com

Murp said:
Bit stumped by this control. I am using it to display HTML stored in a table
on a form. The OnCurrent event procedure on the form is:

Me.ocxWebBrwsr.Object.Document.body.innerHTML =
& _
"<FONT size=-1>" & [DescWeb] & strAuth & strDetail & "</font> </body>"

When I open the form, I get the following error:
"Run-time error 91: Object variable or With block variable not set"

If I click "End", the form opens, but there is nothing in the control. BUT
every subsequent record I go to works fine from that point on.

Any help would be much appreciated.
 
R

Ron Weiner

Siggi

I have never attempted the set the InnerHTML property of the Web Browser
object directly. Instead I Open, Write, and Close the document. You might
refactor your code thusly:

Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Document.Open "text/html", "replace"
Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText
Form_DiaryError.WebBrowser9.Document.Close

and see if this makes your intermittent problem go away.
--
Ron W
www.WorksRite.com
Siggi Bjarnason said:
OK I've got a similar issue. Here is snipped from my code:
Form_DiaryError.txtError.Value = oPoster.responseText
Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Object.Document.body.innerHTML =
oPoster.responseText

First of I periodically get the object not set error below, but never when I
step through the code. When the code executes without an error the browser is
always blank even though the text box contains the HTML code.

Any ideas?

Ron Weiner said:
Yo Yo Ma

The Microsoft Web Browser control needs to be initalized by browsing to
"about:blank" before you go to use it for the first time. I recommend that
in the Foem_Load event yo add some code like:

Define this constant somewhere in the General section of the forms code

Const NAV_NO_HISTORY = &H2

Then in the Foem_Load() event add this

' Initalize Browser control by navigating to nowhere
wbMain.Navigate "about:blank", NAV_NO_HISTORY

Once that is done I have found that I am able to manulipate the control and
all of its properties without error.

Ron W
www.WorksRite.com

Murp said:
Bit stumped by this control. I am using it to display HTML stored in a table
on a form. The OnCurrent event procedure on the form is:

Me.ocxWebBrwsr.Object.Document.body.innerHTML =
& _
"<FONT size=-1>" & [DescWeb] & strAuth & strDetail & "</font> </body>"

When I open the form, I get the following error:
"Run-time error 91: Object variable or With block variable not set"

If I click "End", the form opens, but there is nothing in the control. BUT
every subsequent record I go to works fine from that point on.

Any help would be much appreciated.
 
S

Siggi Bjarnason

That did make the error go away but the nothing is rendering. Maybe there is
an error or something in the stream preventing it from rendering.

Ron Weiner said:
Siggi

I have never attempted the set the InnerHTML property of the Web Browser
object directly. Instead I Open, Write, and Close the document. You might
refactor your code thusly:

Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Document.Open "text/html", "replace"
Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText
Form_DiaryError.WebBrowser9.Document.Close

and see if this makes your intermittent problem go away.
--
Ron W
www.WorksRite.com
Siggi Bjarnason said:
OK I've got a similar issue. Here is snipped from my code:
Form_DiaryError.txtError.Value = oPoster.responseText
Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Object.Document.body.innerHTML =
oPoster.responseText

First of I periodically get the object not set error below, but never when I
step through the code. When the code executes without an error the browser is
always blank even though the text box contains the HTML code.

Any ideas?

Ron Weiner said:
Yo Yo Ma

The Microsoft Web Browser control needs to be initalized by browsing to
"about:blank" before you go to use it for the first time. I recommend that
in the Foem_Load event yo add some code like:

Define this constant somewhere in the General section of the forms code

Const NAV_NO_HISTORY = &H2

Then in the Foem_Load() event add this

' Initalize Browser control by navigating to nowhere
wbMain.Navigate "about:blank", NAV_NO_HISTORY

Once that is done I have found that I am able to manulipate the control and
all of its properties without error.

Ron W
www.WorksRite.com

Bit stumped by this control. I am using it to display HTML stored in a
table
on a form. The OnCurrent event procedure on the form is:

Me.ocxWebBrwsr.Object.Document.body.innerHTML =
"<HTML><HEAD></HEAD><BODY>"
& _
"<FONT size=-1>" & [DescWeb] & strAuth & strDetail & "</font> </body>"

When I open the form, I get the following error:
"Run-time error 91: Object variable or With block variable not set"

If I click "End", the form opens, but there is nothing in the control. BUT
every subsequent record I go to works fine from that point on.

Any help would be much appreciated.
 
S

Siggi Bjarnason

The stream works just fine when I open it up in external IE as this:
Form_DiaryError.txtError.Value = oPoster.responseText
Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Document.Open "text/xml", "replace"
Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText
Form_DiaryError.WebBrowser9.Document.Close
Set InfoFile = fso.CreateTextFile("c:\stream.html", True)
InfoFile.WriteLine oPoster.responseText
InfoFile.Close
objShell.ShellExecute "iexplore", "c:\stream.html"

The HTML is rendered in the normal IE but the embeded IE on form DiaryError
remains blank. Weirdly enough the following code makes the embeded IE render.
This is code on the DiaryError form and I have to invoke it by clicking in
the text box and clicking someplace else.

Private Sub txtError_Exit(Cancel As Integer)

Me.WebBrowser9.Object.Document.body.innerHTML = Me.txtError.Value

End Sub

Any thoughts?

Siggi Bjarnason said:
That did make the error go away but the nothing is rendering. Maybe there is
an error or something in the stream preventing it from rendering.

Ron Weiner said:
Siggi

I have never attempted the set the InnerHTML property of the Web Browser
object directly. Instead I Open, Write, and Close the document. You might
refactor your code thusly:

Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Document.Open "text/html", "replace"
Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText
Form_DiaryError.WebBrowser9.Document.Close

and see if this makes your intermittent problem go away.
--
Ron W
www.WorksRite.com
Siggi Bjarnason said:
OK I've got a similar issue. Here is snipped from my code:
Form_DiaryError.txtError.Value = oPoster.responseText
Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Object.Document.body.innerHTML =
oPoster.responseText

First of I periodically get the object not set error below, but never when I
step through the code. When the code executes without an error the browser is
always blank even though the text box contains the HTML code.

Any ideas?

:

Yo Yo Ma

The Microsoft Web Browser control needs to be initalized by browsing to
"about:blank" before you go to use it for the first time. I recommend that
in the Foem_Load event yo add some code like:

Define this constant somewhere in the General section of the forms code

Const NAV_NO_HISTORY = &H2

Then in the Foem_Load() event add this

' Initalize Browser control by navigating to nowhere
wbMain.Navigate "about:blank", NAV_NO_HISTORY

Once that is done I have found that I am able to manulipate the control and
all of its properties without error.

Ron W
www.WorksRite.com

Bit stumped by this control. I am using it to display HTML stored in a
table
on a form. The OnCurrent event procedure on the form is:

Me.ocxWebBrwsr.Object.Document.body.innerHTML =
"<HTML><HEAD></HEAD><BODY>"
& _
"<FONT size=-1>" & [DescWeb] & strAuth & strDetail & "</font> </body>"

When I open the form, I get the following error:
"Run-time error 91: Object variable or With block variable not set"

If I click "End", the form opens, but there is nothing in the control. BUT
every subsequent record I go to works fine from that point on.

Any help would be much appreciated.
 
R

Ron Weiner

Siggi

The only thing I can think of this that further down the line you have some
code changes a browser setting or the source text for the page. I do not
see any reason that this code should not work. your could try changing the
line

Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText

to something like:

Form_DiaryError.WebBrowser9.Document.Write "<html><head>Test
Head<br></head><body>Test Body<br></body></html>"

Just to see if a really simple page will render in the browser window.

--
Ron W
www.WorksRite.com
Siggi Bjarnason said:
The stream works just fine when I open it up in external IE as this:
Form_DiaryError.txtError.Value = oPoster.responseText
Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Document.Open "text/xml", "replace"
Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText
Form_DiaryError.WebBrowser9.Document.Close
Set InfoFile = fso.CreateTextFile("c:\stream.html", True)
InfoFile.WriteLine oPoster.responseText
InfoFile.Close
objShell.ShellExecute "iexplore", "c:\stream.html"

The HTML is rendered in the normal IE but the embeded IE on form DiaryError
remains blank. Weirdly enough the following code makes the embeded IE render.
This is code on the DiaryError form and I have to invoke it by clicking in
the text box and clicking someplace else.

Private Sub txtError_Exit(Cancel As Integer)

Me.WebBrowser9.Object.Document.body.innerHTML = Me.txtError.Value

End Sub

Any thoughts?

Siggi Bjarnason said:
That did make the error go away but the nothing is rendering. Maybe there is
an error or something in the stream preventing it from rendering.

Ron Weiner said:
Siggi

I have never attempted the set the InnerHTML property of the Web Browser
object directly. Instead I Open, Write, and Close the document. You might
refactor your code thusly:

Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Document.Open "text/html", "replace"
Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText
Form_DiaryError.WebBrowser9.Document.Close

and see if this makes your intermittent problem go away.
--
Ron W
www.WorksRite.com
message OK I've got a similar issue. Here is snipped from my code:
Form_DiaryError.txtError.Value = oPoster.responseText
Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Object.Document.body.innerHTML =
oPoster.responseText

First of I periodically get the object not set error below, but never when
I
step through the code. When the code executes without an error the browser
is
always blank even though the text box contains the HTML code.

Any ideas?

:

Yo Yo Ma

The Microsoft Web Browser control needs to be initalized by browsing to
"about:blank" before you go to use it for the first time. I recommend
that
in the Foem_Load event yo add some code like:

Define this constant somewhere in the General section of the forms code

Const NAV_NO_HISTORY = &H2

Then in the Foem_Load() event add this

' Initalize Browser control by navigating to nowhere
wbMain.Navigate "about:blank", NAV_NO_HISTORY

Once that is done I have found that I am able to manulipate the control
and
all of its properties without error.

Ron W
www.WorksRite.com

Bit stumped by this control. I am using it to display HTML stored in a
table
on a form. The OnCurrent event procedure on the form is:

Me.ocxWebBrwsr.Object.Document.body.innerHTML =
"<HTML><HEAD></HEAD><BODY>"
& _
"<FONT size=-1>" & [DescWeb] & strAuth & strDetail & "</font>
When I open the form, I get the following error:
"Run-time error 91: Object variable or With block variable not set"

If I click "End", the form opens, but there is nothing in the control.
BUT
every subsequent record I go to works fine from that point on.

Any help would be much appreciated.
 
S

Siggi Bjarnason

No dice. I guess I'll be opening up a case with PSS on this one as it is
totally weird. Thanks for your help though.

Ron Weiner said:
Siggi

The only thing I can think of this that further down the line you have some
code changes a browser setting or the source text for the page. I do not
see any reason that this code should not work. your could try changing the
line

Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText

to something like:

Form_DiaryError.WebBrowser9.Document.Write "<html><head>Test
Head<br></head><body>Test Body<br></body></html>"

Just to see if a really simple page will render in the browser window.

--
Ron W
www.WorksRite.com
Siggi Bjarnason said:
The stream works just fine when I open it up in external IE as this:
Form_DiaryError.txtError.Value = oPoster.responseText
Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Document.Open "text/xml", "replace"
Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText
Form_DiaryError.WebBrowser9.Document.Close
Set InfoFile = fso.CreateTextFile("c:\stream.html", True)
InfoFile.WriteLine oPoster.responseText
InfoFile.Close
objShell.ShellExecute "iexplore", "c:\stream.html"

The HTML is rendered in the normal IE but the embeded IE on form DiaryError
remains blank. Weirdly enough the following code makes the embeded IE render.
This is code on the DiaryError form and I have to invoke it by clicking in
the text box and clicking someplace else.

Private Sub txtError_Exit(Cancel As Integer)

Me.WebBrowser9.Object.Document.body.innerHTML = Me.txtError.Value

End Sub

Any thoughts?

Siggi Bjarnason said:
That did make the error go away but the nothing is rendering. Maybe there is
an error or something in the stream preventing it from rendering.

:

Siggi

I have never attempted the set the InnerHTML property of the Web Browser
object directly. Instead I Open, Write, and Close the document. You might
refactor your code thusly:

Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Document.Open "text/html", "replace"
Form_DiaryError.WebBrowser9.Document.Write oPoster.responseText
Form_DiaryError.WebBrowser9.Document.Close

and see if this makes your intermittent problem go away.
--
Ron W
www.WorksRite.com
message OK I've got a similar issue. Here is snipped from my code:
Form_DiaryError.txtError.Value = oPoster.responseText
Form_DiaryError.WebBrowser9.navigate "about:blank", &H2
Form_DiaryError.WebBrowser9.Object.Document.body.innerHTML =
oPoster.responseText

First of I periodically get the object not set error below, but never when
I
step through the code. When the code executes without an error the browser
is
always blank even though the text box contains the HTML code.

Any ideas?

:

Yo Yo Ma

The Microsoft Web Browser control needs to be initalized by browsing to
"about:blank" before you go to use it for the first time. I recommend
that
in the Foem_Load event yo add some code like:

Define this constant somewhere in the General section of the forms code

Const NAV_NO_HISTORY = &H2

Then in the Foem_Load() event add this

' Initalize Browser control by navigating to nowhere
wbMain.Navigate "about:blank", NAV_NO_HISTORY

Once that is done I have found that I am able to manulipate the control
and
all of its properties without error.

Ron W
www.WorksRite.com

Bit stumped by this control. I am using it to display HTML stored in a
table
on a form. The OnCurrent event procedure on the form is:

Me.ocxWebBrwsr.Object.Document.body.innerHTML =
"<HTML><HEAD></HEAD><BODY>"
& _
"<FONT size=-1>" & [DescWeb] & strAuth & strDetail & "</font>
When I open the form, I get the following error:
"Run-time error 91: Object variable or With block variable not set"

If I click "End", the form opens, but there is nothing in the control.
BUT
every subsequent record I go to works fine from that point on.

Any help would be much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top