Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Displaying the Sub or Function Name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FunkySquid - 29 May 2008 14:05 GMT
Is there anyway of displaying the current sub or function name that is
running?

Something like:

Sub DisplaySubName()
 MsgBox ThisSub.Name
End Sub
FSt1 - 29 May 2008 19:15 GMT
hi
you can use the status bar.
when writing the sub, you know the name of the sub your are writing.
at the beginning of the sub add this like
application.statusbar = "sub now running = mysub"
at the end of the sub ad this line
application.statusbar = False

the name of the sub will appear in the lower left on the status bar.

Regards
FSt1

> Is there anyway of displaying the current sub or function name that is
> running?
[quoted text clipped - 4 lines]
>   MsgBox ThisSub.Name
> End Sub
Susan - 29 May 2008 19:32 GMT
that's cool.  is there any way to have the macro pull out the name
automatically without hard coding it?
just wondering.
:)
susan

> hi
> you can use the status bar.
[quoted text clipped - 19 lines]
>
> - Show quoted text -
FSt1 - 29 May 2008 19:55 GMT
hi
I don't think you can while the code is running because you have to run code
to to find the sub name and since you can't run 2 sub at the same time you
would have to incorperated the "find" code into the running sub.  and if
using a message box, that would stop code from running while the message box
was up since the message box is modal. best just to use the status bar

Regards
FSt1

> that's cool.  is there any way to have the macro pull out the name
> automatically without hard coding it?
[quoted text clipped - 25 lines]
> >
> > - Show quoted text -
Susan - 29 May 2008 20:10 GMT
yes, i see.
i tend to have one "overview" sub (like a userform sub) that calls all
my sub-subs (for lack of a better term) & i could put it in there
before calling each of them (& afterwards).  such as:

sub commandbutton1_click()
application.statusbar = "sub now running = find_terms"
Call find_terms
application.statusbar = false
application.statusbar = "sub now running = insert_data"
Call insert_data
application.statusbar = false
end sub

thanks for the info.
:)
susan

> hi
> I don't think you can while the code is running because you have to run code
[quoted text clipped - 37 lines]
>
> - Show quoted text -
FSt1 - 29 May 2008 21:58 GMT
looks like you got ahold of that handle pretty good. that should work nicely
for you.

Regards
FSt1

> yes, i see.
> i tend to have one "overview" sub (like a userform sub) that calls all
[quoted text clipped - 55 lines]
> >
> > - Show quoted text -
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.