runtime error: 91 Object variable or with block variable not set 
Author Message
 runtime error: 91 Object variable or with block variable not set

Hello,

I am experiencing this runtime error 91 Object variable or with block
variable not set ONLY in the exe-File. If I run the program out of the IDE
there is never a problem. This makes it tricky to trace.

I have two programs using the webbrowser control, both having this problem.

One program may run for hours doing the same thing over and over, so the
code should be ok. But sometimes I get this error.

Is this a known bug?

regards
Gunter



Tue, 12 Apr 2005 07:41:02 GMT  
 runtime error: 91 Object variable or with block variable not set
At the top of all your modules do you have :-

    Option Explicit : DefObj A-Z

(tip from Joe (Nuke Me) Foster - that has shown up many potential
problems for me)

Also wherever you have a dynamic array do you do :-

    Dim MyArray() As String
....
    ReDim MyArray( 1 To Count )

If you do not do this then there is a slight possibility that 'scope'
problems will turn up - and the wrong Array is redimensioned.

Realistically you need to put some sort of routine tracing stuff in
your code :-
   Private Sub MySub( Var1 As ... )
         PushLoc "MySub"

         ....
        PopLoc "MySub"
  End Sub

That will give you a clear idea where the error lies.

Another method is to simply put in Line Numbers
- these are still supported in VB
- this will help you locate (at least roughly) the area in which the
problem shows itself.

Also have a look at your Compiler options
- do you have any 'Advanced Optimizations' set ?

The fact that it turns up in *two* programs is helpful
- what code is shared between the two.
- or common to both Apps

On Fri, 25 Oct 2002 01:41:02 +0200, "Gunter Schmidt"

Quote:

>Hello,

>I am experiencing this runtime error 91 Object variable or with block
>variable not set ONLY in the exe-File. If I run the program out of the IDE
>there is never a problem. This makes it tricky to trace.

>I have two programs using the webbrowser control, both having this problem.

>One program may run for hours doing the same thing over and over, so the
>code should be ok. But sometimes I get this error.

>Is this a known bug?

>regards
>Gunter



Tue, 12 Apr 2005 16:05:42 GMT  
 runtime error: 91 Object variable or with block variable not set
Gunter,

Most likely you're trying to access an object which exists only under
certain circumstances. Make sure you're checking If Not (xObj Is
Nothing) before touching such objects.

Hope this helps,

Max Kudrenko
Brainbench MVP Program for Visual Basic
www.brainbench.com

Quote:

> Hello,
> I am experiencing this runtime error 91 Object variable or with block
> variable not set ONLY in the exe-File. If I run the program out of the IDE
> there is never a problem. This makes it tricky to trace.
> I have two programs using the webbrowser control, both having this problem.
> One program may run for hours doing the same thing over and over, so the
> code should be ok. But sometimes I get this error.
> Is this a known bug?
> regards
> Gunter



Tue, 12 Apr 2005 19:34:29 GMT  
 runtime error: 91 Object variable or with block variable not set
Quote:
> >I am experiencing this runtime error 91 Object variable or with block
> >variable not set ONLY in the exe-File. If I run the program out of the
IDE
> >there is never a problem. This makes it tricky to trace.
----- Original Message -----

Newsgroups: comp.lang.basic.visual.misc
Sent: Friday, October 25, 2002 10:05 AM
Subject: Re: runtime error: 91 Object variable or with block variable not
set

> At the top of all your modules do you have :-

>     Option Explicit : DefObj A-Z

> (tip from Joe (Nuke Me) Foster - that has shown up many potential
> problems for me)

> Also wherever you have a dynamic array do you do :-

>     Dim MyArray() As String
> ....
>     ReDim MyArray( 1 To Count )

> If you do not do this then there is a slight possibility that 'scope'
> problems will turn up - and the wrong Array is redimensioned.

> Realistically you need to put some sort of routine tracing stuff in
> your code :-
>    Private Sub MySub( Var1 As ... )
>          PushLoc "MySub"

>          ....
>         PopLoc "MySub"
>   End Sub

> That will give you a clear idea where the error lies.

> Another method is to simply put in Line Numbers
> - these are still supported in VB
> - this will help you locate (at least roughly) the area in which the
> problem shows itself.

> Also have a look at your Compiler options
> - do you have any 'Advanced Optimizations' set ?

> The fact that it turns up in *two* programs is helpful
> - what code is shared between the two.
> - or common to both Apps

Tx, I keep it in mind.
For now I do not get this error, maybe I just needed to reboot the system.
Both programs do use the microsoft HTML Object library, so I figure it might
be connected with that.

regards
Gunter



Tue, 12 Apr 2005 19:43:35 GMT  
 runtime error: 91 Object variable or with block variable not set
Max,

your were right.

Following code caused the error:

Me.brwWebBrowser1.Document.write HTML_String

Why? With IDE the WebBrowser gets initialised, during runtime not.

Since I get the data I need from an Inet-Control, I do not Navigate with the
WebBrowser Control.

Now I included following line, which solved the problem.
If Me.brwWebBrowser1.Document Is Nothing Then Me.brwWebBrowser1.Navigate ""

But I think there must a better way to initialize the document.

Gunter



Quote:
> Gunter,

> Most likely you're trying to access an object which exists only under
> certain circumstances. Make sure you're checking If Not (xObj Is
> Nothing) before touching such objects.

> Hope this helps,

> Max Kudrenko
> Brainbench MVP Program for Visual Basic
> www.brainbench.com




Quote:
> > Hello,
> > I am experiencing this runtime error 91 Object variable or with block
> > variable not set ONLY in the exe-File. If I run the program out of the
IDE
> > there is never a problem. This makes it tricky to trace.
> > I have two programs using the webbrowser control, both having this
problem.
> > One program may run for hours doing the same thing over and over, so the
> > code should be ok. But sometimes I get this error.
> > Is this a known bug?
> > regards
> > Gunter



Wed, 13 Apr 2005 05:40:12 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Runtime error 91/Object variable or With block variable not set problems

2. Object variable or With block variable not set (Error 91)

3. error 91 Object Variable o on with block variable is not set

4. Object variable or With block variable not set (Error 91) Please Help

5. Run Time Error 91: Object variable or With Block variable not set

6. VB 5.0 - Error:91 Object Variable Or With Block Variable Not Set

7. Object variable or With block variable not set (Error 91)

8. Error 91 Object variable or With-Block, variable not set

9. Debugging COM+ Componets -- Runtime error 91- Object variable or with block not set

10. Runtime error 91: Object or with block variable not defined

11. Error 91-Object or block with variable not set

12. error 91 - object or block with variable not set

 

 
Powered by phpBB® Forum Software