Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which procedure called? 1

Status
Not open for further replies.

goldenboy10

Technical User
Feb 17, 2009
2
US
Hi all,

Is it possible to know the name of the procedure which called the proc A?

Exple:
Sub B()
call A
...
end sub
Sub C()
call A
...
end sub

Sub A()
If Sub B called me then
Workbooks.open (Path B)
elseif Sub called me then
Workbooks.open (path C)
end if
...
end sub

Please advise.

Regds
 
How are ya goldenboy10 . . .

Add an arguement parameter to [blue]Sub A()[/blue] and pass an Identifier:
Code:
[blue]Sub B()
 Call A("SubB")
 '...
End Sub

Sub C()
 Call A("SubC")
 '...
End Sub

Sub A([purple][b]Caller[/b][/purple] As String)
 If [purple][b]Caller[/b][/purple] = "SubB" Then
    Workbooks.open (Path B)
 ElseIf [purple][b]Caller[/b][/purple] = "SubC then" Then
    Workbooks.open (path C)
 End If
 '...
End Sub[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
goldenboy10 . . .

Who's the IceMan? [surprise]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
a somewhat more generic use of the concept would be to define a table to hold the 'call stack' information and place all object calls / instances in the table. Including a date time stamp with each call would enable any process to determine where it was called from.

This CAN be quite useful in debugging.



MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top