runtime func name

Mod

DoCmd.PostForHelp
Local time
Yesterday, 19:33
Joined
May 4, 2004
Messages
70
Is it possible to find the name of the current executing function at runtime? Something like:
Code:
sub ThisSubroutine
     MsgBox([color=red]This.RunTimeObjects.CurrentFunction.Name[/color])
End Sub
Of course, the whole red part is just some kind of wierd object I made up. But if an object like that does exist, or even just some way to find the name of the function that's currently executing, it would make my life tons easier.
 
Yes.. but you need the line number. Look at:

Application.VBE.ActiveCodePane.CodeModule.ProcOfLine


That's why it's good to add line numbers to your code :)
 
Last edited:
Ack, I can't find the library to reference for VBE (VBIDE) does anyone know what the filename is for this library?

EDIT:
PS Does anyone else find it difficult to browse the list of available references? Unless I know the full name of the library it can be challenging.
 
Last edited:
Microsoft Visual Basic for Applications Extensibility 5.3
 
Last edited:
modest said:
Microsoft Visual Basic for Applications Extensibility 5.3
Thanks, I found it. Unfortunately for me, it's not the shortcut I was looking for (if i know the line number, i might as well just know the name of the function, heh). I did find the nice property Application.VBE.ActiveCodePane.CodeModule.Parent.Name which will return the name of the active module. That's some good anyway.

Thanks again. :)
 
You should start including line numbers with your code. You'll find that it helps for error handling and to do other stuff such as this.
 

Users who are viewing this thread

Back
Top Bottom