View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default Can a Sub/Function print the names of its callers?

On Tue, 13 Jul 2010 13:43:35 -0400, wrote:

If I detect an error in a Sub/Function, I would like to be able to print
the sequence of callers. Line numbers would be great too if that is
possible.

Example:

sub Main()
call Sub
end sub

sub Sub1()
call sub2(3)
end sub

Sub Sub2(n as long)
if n 2 then
'Code to print
' Sub 2 called with value n
' from Sub1 at line 2
' from Main at line 2
end
end if
end sub


Check out the UserName property of the Application object.