Finding Procedure which generated error

L

LS

Hi

I have a worksheet with several modules each with several procedures.
I have dealt with all the errors I can anticipate (which means there
must be some that I have not dealt with!) and have handled those with
a common 'if all else fails' error procedure. This will leave the
worksheet in a 'safe', mode ensuring sheets are hidden or protected.

The procedure also generates a message showing Err.Number and
Err.Description, however it would be useful to know which procedure
actually generated the error so that when I get a call about it I know
where to start looking.

I tried using Err.Source but that just gives the name of the entire
project - not the module or better still, the procedure name.
Is this possible?

Thanks

LS
 
T

Tom Ogilvy

Only if you write code that passes the information to your error handler.
In other words, no there is no property or method that will return any
information about where the error occured.

that said, here is some discussion on the arcane ERL function

http://groups.google.com/[email protected]
 
B

Bob Phillips

Have to do it manually.Create a public variable and set that in each
procedure, like

Dim callProc As String

Sub proc1()

callProc="proc1"
'...
End Sub


Sub proc2()

callProc="proc2"
'...
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
L

LS

Many thanks to both Bob & Tom for their replies.
I used a variable in each module and it works fine.

LS
 
Top