VBA code executes fine, but compiler throws error. Huh?

B

baobob

I continue to have severe problems with Excel 97 SR2 crashing while
editing, compiling & running VBA.

I DO promise to upgrade soon. But meanwhile:

On relaunching Excel after its last crash, all code runs fine but the
compiler throws an error.

On selecting Debug / Compile VBAProject, error "User-defined type not
defined" appears. Nor does the compiler highlight in its usual yellow
what line is causing this supposed error.

I have three modules and they're all intact. If I deliberately make a
syntax error anywhere, execution then correctly chokes and stops on
the offending line.

Does anyone recognize this problem & how to fix it?

(And more basic Q: Why doesn't Excel's left hand know what its right
hand is doing?)

Thanks much.

***
 
J

Jim Cone

Excel 97 has a better help file than any of the later versions.
XL2000 has particularly bad help file.
Excel 97, in general, is faster than anything that came after.
However, MS has stopped releasing security fixes for Excel 97.
It is difficult to find the words to express my true feelings about xl2007.

As for your compile problem...
It sounds as if you are not using "Option Explicit" as the first line in each module.
If that is the case, you could have simply misspelled a word in your code,
leaving XL to think it is a custom Type declaration.

I saw a recent post where the same error was generated by spelling Variant as varaint.

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




<[email protected]>
wrote in message
I continue to have severe problems with Excel 97 SR2 crashing while
editing, compiling & running VBA.
I DO promise to upgrade soon. But meanwhile:
On relaunching Excel after its last crash, all code runs fine but the
compiler throws an error.
On selecting Debug / Compile VBAProject, error "User-defined type not
defined" appears. Nor does the compiler highlight in its usual yellow
what line is causing this supposed error.
I have three modules and they're all intact. If I deliberately make a
syntax error anywhere, execution then correctly chokes and stops on
the offending line.
Does anyone recognize this problem & how to fix it?
(And more basic Q: Why doesn't Excel's left hand know what its right
hand is doing?)
Thanks much.
 
B

baobob

Jim:

Thanks very much for reply.

Well, I have 3 modules, and yes, those 2 that I've been mucking with
do have 'Option Explicit'. The 3rd module that I haven't touched only
contains a bunch of one-line UDFs that are macro keystroke shortcuts
for changing font, color. But thanks to your reminder, I added 'Option
Explicit' to it too.

***

But in the meantime, I've changed to my other PC with Excel 2002 on
it, and the error is still occurring, but in the reverse: My VBA
compiles fine, but I'm getting that 'User-defined function not
defined' message while out in the workbook, when I exit certain cells
that contain calls to my UDFs. But the error displays only
sporadically (meaning when the compiler, or whatever it is that's
throwing the error, has to search beyond a cache of some sort....?
Just an idle hypothesis.)

Anyway, I'll create another thread for this problem if necessary.

***

Your remarks re. Excel 97 are very interesting. Yes, Excel 97's Help
seems very good, and I've always liked it.

I absolutely LOATHE Angel Soft's later Help paradigm, where you, like,
type in one or more keywords, then get some results, then try find in
those results what you're looking for. Everyone I know has been
puzzled by why most (and sometimes all) of those results are
completely off-topic, and worse are (or at least last time I looked,
which could be a few yrs.) not even alphabetized. I mean, huh?

I find one and only one kind of help interface really usable: a simple
index of all the topics, functions, keywords, etc. that the
application contains.

Well, thanks again.

***
 
Top