Procedure Name as a property?
Maybe I'm missing something, but I think this falls into the "you have to
know the answer before I can give you the answer" type of thing. I could be
wrong.
But consider that for you to get the name of the current module and
procedure name, that procedure is going to have to be running, and where I
think you're looking for a generic answer like:
MsgBox "Module: " & magicRoutineToGetModuleName & vbCRLF & _
"Routine: " & magicRoutineToGetRoutineName
Since that's going to be in the routine which you are presumably writing,
then you know the answer and I'd just hard code it, since I don't know the
magic... routines in question. Example ... in a module named Module1 (until
you rename it):
Sub TellSecrets()
MsgBox "Module: Module1" & vbCRLF & "Routine: TellSecrets"
End Sub
Now you could set up a module-scope variable ahead of the first routine in a
module like this:
Const thisModuleName = "Module1" ' change as you change module's name
Sub FindSecrets()
Const myRoutineName = "FindSecrets" ' again, change for each routine
'and then you could call a public function to 'tell all'
TellSecrets thisModuleName, myRoutineName
End Sub
Public Function TellSecrets(modName as String, subName as String) as Variant
MsgBox "Module: " & modName & vbCRLF & _
"Routine: " & subName
End Function
"Stu W" wrote:
Is there a way to refer to the currently running module and procedure name in
a msgbox?
|