Syntax 

CallersLine[(Depth)]


Group 

Miscellaneous 


Description 

Return the caller's line as a text string.

The text format is: "[macroname|subname#linenum] linetext".

linenum is the absolute line number in the file (includes lines hidden by the editor)


Parameters

Description

Depth 

This integer value indicates how deep into the stack to get the caller's line. If Depth = -1 then return the current line. If Depth = 0 then return the calling subroutine's current line, etc.. If Depth > 0 then return the calling subroutine that (Depth+1) levels up. If Depth is greater than or equal to the call stack depth then a null string is returned. If Depth < -1 then return the calling subroutine -Depth-2 from the topmost level. If Depth is less than or equal to -(the call stack depth)-2 then a null string is returned. If this value is omitted then the depth is 0.


See Also 

CallersSymbol


Example

Sub Main

    A

End Sub

Sub A

    B

End Sub

Sub B

    C

End Sub

Sub C

    Debug.Print CallersLine(-1) '"[?A1|C# 12] Debug.Print CallersLine$(-1&)"

    Debug.Print CallersLine     '"[?A1|B#  9] C"

    Debug.Print CallersLine(1)  '"[?A1|A#  6] B"

    Debug.Print CallersLine(2)  '"[?A1|Main#  3] A"

    Debug.Print CallersLine(3)  '""

    Debug.Print CallersLine(-2) '"[?A1|Main#  3] A"

    Debug.Print CallersLine(-3) '"[?A1|A#  6] B"

    Debug.Print CallersLine(-4) '"[?A1|B#  9] C"

    Debug.Print CallersLine(-5) '"[?A1|C# 20] Debug.Print CallersLine$(-5&)"

    Debug.Print CallersLine(-6) '""

End Sub