Error Handling

B

Billy Boone

I'm relatively new to Excel programming (but not programming in general) -
so I have written some macros and part of the error handling - I wanted to
display an error message - including the macro that had the problem. I was
expecting to use Err.Source - but that returns Microsoft Excel. Any way to
get the source macro function name (short of hard coding a string)?

BBB
 
R

Rob Bovey

Billy Boone said:
I'm relatively new to Excel programming (but not programming in general) -
so I have written some macros and part of the error handling - I wanted to
display an error message - including the macro that had the problem. I
was
expecting to use Err.Source - but that returns Microsoft Excel. Any way
to
get the source macro function name (short of hard coding a string)?

Hi Billy,

Unfortunately, hard-coding the macro name in a string is the only way to
know where the error occurred. VBA does support line numbering, and there
are utilities out there that will line number your code so you can retrieve
the number of the line of code that caused the error, but I've personally
found that line numbering is a lot more trouble than it's worth.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm
 

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