Sub Routine Name

  • Thread starter Thread starter Wembly
  • Start date Start date
W

Wembly

Hi,

I want to retrieve the name of the sub procedure that is
currently executing as part of the sub procedure code. How
is this done?

Wembly
 
In general, no can do. For example, there is no way for the next msgbox to
know the name of the sub in which it is running:

sub mysub()
msgbox ???
end sub

Of course, you could define a constant for the name (seperately, in each
sub):

sub mysub()
CONST MYNAME = "mysub"
msgbox MYNAME
end sub

HTH,
TC
 
If the Sub is an event ie Click then you can use


Private Sub Command0_Click()
Dim ctlCurrentControl As Control
Set ctlCurrentControl = Screen.ActiveControl
MsgBox ctlCurrentControl.Name
End Sub

OR JUST

Private Sub Command0_Click()
MsgBox Me.ActiveControl.Name
End Sub

Although i may have the wrong idea as to what you want to do
Dave
 
Back
Top