Excel 2003/vbx macro errors.

P

Phil B

I'm developing some vba macros under excel 2003 and am (naturally) getting
errors.
Compile time errors highlight the offending line, but seemingly not run time
errors.

All I'm getting is a helpful message eg 'Invalid procedure call or argument'
but no clue as to which line of code is giving this.
Isn't it possible to get the environment to highlight the offending source
line?
There must be a better way than a liberal sprinkling of print and msgbox
diagnostics.

regards
Phil B
 
C

Clif McIrvin

Phil B said:
I'm developing some vba macros under excel 2003 and am (naturally)
getting errors.
Compile time errors highlight the offending line, but seemingly not
run time errors.

All I'm getting is a helpful message eg 'Invalid procedure call or
argument' but no clue as to which line of code is giving this.
Isn't it possible to get the environment to highlight the offending
source line?
There must be a better way than a liberal sprinkling of print and
msgbox diagnostics.


Hi Phil - are you using [ On Error .... ] statements in your code? For
initial debugging you might comment them all out so that VBA will give
you the option of dropping into the debugger on an error ... and then
the error line will be highlighted for you.

If that doesn't help, the message indicates that your code is calling a
sub or function and the call is failing ... perhaps you wrote the
procedure with a required parameter and your call isn't providing it.

My standard technique for tracking down " strange " errors is exactly
what you mention .. judicious (liberal ?) use of debug.print (I
sometimes use msgbox, but generally prefer the print. You should be
able to identify "milestones" in your code this way, and narrow down
your investigation area.
 
J

Jim Cone

Under Tools | Options | General (tab) in the VBE, change Break on unhandled errors to Break on all
errors.
 

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