Sub Routine Name

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
 
T

TC

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
 
D

Dave

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top