Run-time error '91'

Run-time error '91'

Anonymous
Not applicable
316 Views
4 Replies
Message 1 of 5

Run-time error '91'

Anonymous
Not applicable
Hello all,

It is time to revisit this error because it is driving me insane.

I am getting the following error:

Run-time error '91'':
object variable or With block variable not set

It happens only on a few machines. We are running NT sp4, acad 14.01.

My program is a catalog program that takes a block name from a database and
inserts it into a drawing. I am using evallispexpr via acadunsupp.arx to do
the actual insertion into the drawing. The program gets all the way to the
insertion, but when the insert button is clicked .... BOOM. On most
computers it is working fine. On about three of them I get this error.

What can it be?

Any Ideas?

TIA

--
Mark Smith
Air Gage Co.
masmith@airgage.com
0 Likes
317 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Mark,
The cause of the that error may be as simple as a missing search path in
acad, then again. VBA can not find the block you are setting to a variable or
cannot set it for some other reason. In any case I'm betting that your program
is stalling on a set statement. Check your paths, if that's not the problem and
you feel comfortable, post a clip of the relevant code.
-Josh

Mark Smith wrote:

> Hello all,
>
> It is time to revisit this error because it is driving me insane.
>
> I am getting the following error:
>
> Run-time error '91'':
> object variable or With block variable not set
>
> It happens only on a few machines. We are running NT sp4, acad 14.01.
>
> My program is a catalog program that takes a block name from a database and
> inserts it into a drawing. I am using evallispexpr via acadunsupp.arx to do
> the actual insertion into the drawing. The program gets all the way to the
> insertion, but when the insert button is clicked .... BOOM. On most
> computers it is working fine. On about three of them I get this error.
>
> What can it be?
>
> Any Ideas?
>
> TIA
>
> --
> Mark Smith
> Air Gage Co.
> masmith@airgage.com
0 Likes
Message 3 of 5

Anonymous
Not applicable
Hi Josh,

Thanks for the reply, I forgot to mention that it is a VB application not
VBA. I don't know if this has any bearing on your response or not.

I still think that it seems odd that the same program will work on one
machine and not another. They both are running the same NT service pack,
the same version of the EXE file, the same release of AutoCAD.... Why
would it fail to insert a block on one machine and not the other?

I will check into it

--
Mark Smith
Air Gage Co.
masmith@airgage.com

Minkwitz Design wrote in message
news:381E1242.8C5719D8@xta.com...
> Mark,
> The cause of the that error may be as simple as a missing search path
in
> acad, then again. VBA can not find the block you are setting to a variable
or
> cannot set it for some other reason. In any case I'm betting that your
program
> is stalling on a set statement. Check your paths, if that's not the
problem and
> you feel comfortable, post a clip of the relevant code.
> -Josh
>
> Mark Smith wrote:
>
> > Hello all,
> >
> > It is time to revisit this error because it is driving me insane.
> >
> > I am getting the following error:
> >
> > Run-time error '91'':
> > object variable or With block variable not set
> >
> > It happens only on a few machines. We are running NT sp4, acad 14.01.
> >
> > My program is a catalog program that takes a block name from a database
and
> > inserts it into a drawing. I am using evallispexpr via acadunsupp.arx
to do
> > the actual insertion into the drawing. The program gets all the way to
the
> > insertion, but when the insert button is clicked .... BOOM. On most
> > computers it is working fine. On about three of them I get this error.
> >
> > What can it be?
> >
> > Any Ideas?
> >
> > TIA
> >
> > --
> > Mark Smith
> > Air Gage Co.
> > masmith@airgage.com
>
0 Likes
Message 4 of 5

Anonymous
Not applicable
Your real problem is insufficient error handling code. For a program to be
reliable, it must check the result of every SET statement. That may sound
extreme, but it is true. Any attempt to set an object variable can fail at
runtime, due to circumstances you cannot anticipate as you write the code. This
is especially true when using automation to operate another program like
AutoCAD.

Some functions raise an error when they fail, while others just return Nothing.
You are getting Nothing, and using the variable anyway, very likely in code
that's far removed from where you supposedly set it. That's why it is essential
to check the result of every SET statement immediately, so the problem is
identified at its source, not somewhere down the road.

To solve your immediate problem, you can start adding these checks in the module
that's calling the Lisp routine, and keep adding them to every module that is in
the code stream for this operation. Just stick a call like this after each SET
statement:

On Error GoTo Failed

Set XXX = blah blah blah
AlertNothing XXX, "XXX", FuncName, Where
...

Failed:
' Whatever

In a code module:

Public Sub AlertNothing(ByVal SomeThing as Object, ByVal What as String, ByVal
Who as String, ByVal Where As String)
If SomeThing Is Nothing Then
MsgBox "Variable " & What & " in module " & Who & " at " & Where,
flags>,"Set Statement Failed:"

' You might even raise an error here, in addition to or instead of the
message box
Err.Raise ...
EndIf
End Sub

Good Luck,

Mark Holder
0 Likes
Message 5 of 5

Anonymous
Not applicable
Mark,
If you are using the AutoCAD library, this may be caused by the acad.tlb
table being improperly registered with the machine. Try changing the
definition of the dim statements to Object intead of AcadApplication or
whatever and see if that works.

--
Andy Cottrell
Applications Engineer
ExcelTech Computer Services
E-Mail: acottrell@exceltech.net

Mark Smith wrote in message
news:7vl1fd$jp13@adesknews2.autodesk.com...
> Hello all,
>
> It is time to revisit this error because it is driving me insane.
>
> I am getting the following error:
>
> Run-time error '91'':
> object variable or With block variable not set
>
> It happens only on a few machines. We are running NT sp4, acad 14.01.
>
> My program is a catalog program that takes a block name from a database
and
> inserts it into a drawing. I am using evallispexpr via acadunsupp.arx to
do
> the actual insertion into the drawing. The program gets all the way to
the
> insertion, but when the insert button is clicked .... BOOM. On most
> computers it is working fine. On about three of them I get this error.
>
> What can it be?
>
> Any Ideas?
>
> TIA
>
> --
> Mark Smith
> Air Gage Co.
> masmith@airgage.com
>
>
0 Likes