error: object variable

  • Thread starter Thread starter Roy Goldhammer
  • Start date Start date
R

Roy Goldhammer

Hello there

On many areas at my program i use objects

if the set action failed, the object won't be set

and if i use this object after word i get the error: 91, object variable,
vith block or with block not set.

Is there a way to know on object if it set or not?
 
Use IsObject to see if a Variant is an Object.

See IsNothing to see if an Object is set or not.

But note that an Object can be set and still
not valid. For example, if you set an object
to be an Excel Application, and then close
the Excel Application, the object is still
an Excel Application object, but not a usable
one:

sub test()
Dim db As DAO.Database
Set db = OpenDatabase(CodeDb.Name)
db.Close
If (db Is Nothing) Then MsgBox "nothing"
MsgBox db.Name
end
 

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

Back
Top