Get the name of a function that calls another function 
Author Message
 Get the name of a function that calls another function

Hi,
I have some code to write to a text file everytime a function is called. I
would like also to write the name of the calling function. Is there any way
for a function to find out the name of the function that is calling it ( and
the component that the calling function is in)?

Thanks,

Jonathan



Mon, 21 Jan 2002 03:00:00 GMT  
 Get the name of a function that calls another function
On Thu, 5 Aug 1999 09:59:10 +0100, "Jonathan Holland"

Quote:

>Hi,
>I have some code to write to a text file everytime a function is called. I
>would like also to write the name of the calling function. Is there any way
>for a function to find out the name of the function that is calling it ( and
>the component that the calling function is in)?

>Thanks,

>Jonathan

Jonathan,

Why don't you just add an extra string parameter to your function, and
then pass the calling function name to it? Something like this:

Sub WriteToTextfile(TextToWrite As String, FunctionCallingMe As
String)
 ...
End Sub

Sub Foo()
  WriteToTextfile "Hello World", "Foo"
End Sub

Mattias

________________________________________________
Mattias "BeeZo" Sj?gren

http://home1.2.sbbs.se/mattias.sjogren/sw/



Mon, 21 Jan 2002 03:00:00 GMT  
 Get the name of a function that calls another function
No.  This information is discarded during compile; if you want to save
it, then you must do it yourself.  

(If you need to do so, for crissake write an add-in to generate the code
- I couldn't sleep if I thought there was someone out there hand-typing,
e.g.,  'MyNameIs = CommmandExit_MouseDown' for every function of an app
<g>)

(If somebody is doing this, _please_ don't tell me!)



Mon, 21 Jan 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Getting the function's name during runtime while running in the scope of the function

2. eval function? how to call dynamic function name

3. getting the function name into a variable

4. (Q) Getting current Sub/Function name (or Object Browser functionality)

5. Getting the User Group name using Current User Function

6. Getting function and procedure names using VBA

7. getting the name of current function/SUb

8. Getting the name of the function currently running

9. Executing Function using String Containing Function Name

10. Returning sub or function name within a specific sub or function

11. How to invoke function when function name is in a string

12. Q-Function-name passing to other function

 

 
Powered by phpBB® Forum Software