"User-defined type not defined"

M

Marty Lee

I'm getting an error message when I try to compile my
project, which reads:

"User-defined type not defined"

Unfortunately, the compiler does not highlight the line
that produces this error. I'm left to guess which one of
dozens of modules, classes, and forms is causing the
error. Is there a way to get the VBA compiler to be a bit
more informative?

Thanks
Marty
(the email address should read @msn rather than @nsm, but
was scrambled to avoid junk mail bots)
 
J

Jay Freedman

Hi, Marty,

I'll assume that you haven't intentionally defined any types, and the error
message is the result of some other sort of problem.

Try simply running the code in the debugger instead of compiling it -- the
debugger may stop on the offending line.

If that doesn't work, check the Tools > References dialog in the VBA editor,
looking for any references that are marked as "Missing". If you find one, it
might mean that the corresponding file (.dll, .ocx, or whatever) is missing
or needs to be reregistered with regsvr32.exe.

If there aren't any missing references, start checking through the Dim
statements and subroutine headers for misspelled data types.
 
M

Marty

Howdy Jay,

Thanks very much! Your idea of using the debugger
resolved the problem, although in a way that surprised
me. I had expected to find that a Dim, Private, or Public
statement had been coded incorrectly. Instead, the
debugger uncovered two places in which the "Set" keyword
was not used when instantiating a custom class. (More
accurately, I was trying to instantiate a custom class
that was a child within another custom class). Running
the debugger allowed me to trap those errors and then I
could correct them. After that, everything ran
smoothly.

I was bumming because the task of examining many
hundreds of declarations would be a huge and very error-
prone task. Does anyone know if there is a utility around
that will examine code for lines missing the "Set"
statement? It would have to be a pretty smart utility!

Marty
(the email address should read @msn rather than @nsm, but
was scrambled to avoid junk mail bots)
 
J

Jay Freedman

Hi, Marty,

If you're thinking of something like the "lint" program in C, I don't think
there's anything like that for VBA. There might be one for VB, but I've
never looked. Otherwise, the "syntax checker" is the debugger.
 

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