Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Fetching a VBA Macro's Name During Execution

In all the macros I write, I put the name of the macro in
the title bar of all Msgbox and Inputbox msgs I generate.
Is there a VBA statement that will fetch the name of the
macro that is executing so I don't have to hard code the
macro name into my msgs? I want something like the code
that fetches the worksheet name that is currently active.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Fetching a VBA Macro's Name During Execution

Hi
AFAIK this is not possible

--
Regards
Frank Kabel
Frankfurt, Germany


SidBord wrote:
In all the macros I write, I put the name of the macro in
the title bar of all Msgbox and Inputbox msgs I generate.
Is there a VBA statement that will fetch the name of the
macro that is executing so I don't have to hard code the
macro name into my msgs? I want something like the code
that fetches the worksheet name that is currently active.

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Fetching a VBA Macro's Name During Execution

Thanx for the reply. I was afraid you'd say that.
-----Original Message-----
Hi
AFAIK this is not possible

--
Regards
Frank Kabel
Frankfurt, Germany


SidBord wrote:
In all the macros I write, I put the name of the macro in
the title bar of all Msgbox and Inputbox msgs I generate.
Is there a VBA statement that will fetch the name of the
macro that is executing so I don't have to hard code the
macro name into my msgs? I want something like the code
that fetches the worksheet name that is currently active.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default Fetching a VBA Macro's Name During Execution

Perhaps this:

Sub GetProcedureName()
Dim Msg As String, Style As Integer, Title As String

'If calling from a commandbar control:
Title = Application.CommandBars.ActionControl.OnAction
'If calling from a worksheet based control (Forms toolbar):
'Title = ActiveSheet.Shapes(Application.Caller).OnAction
Title = Right(Title, Len(Title) - InStr(1, Title, "!"))
Msg = "The rain in Spain falls mainly on the plain. "
Style = vbInformation
MsgBox Msg, Style, Title

End Sub

Regards,
Greg

-----Original Message-----
In all the macros I write, I put the name of the macro in
the title bar of all Msgbox and Inputbox msgs I generate.
Is there a VBA statement that will fetch the name of the
macro that is executing so I don't have to hard code the
macro name into my msgs? I want something like the code
that fetches the worksheet name that is currently active.
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default Fetching a VBA Macro's Name During Execution

Alternatively:

Sub TestGetProcName()
Dim Msg As String, Style As Integer
Msg = "The rain in Spain falls mainly on the plain. "
Style = vbInformation
MsgBox Msg, Style, GetProcName
End Sub

Function GetProcName()
Dim Txt As String
On Error Resume Next
With Application
Txt = .CommandBars.ActionControl.OnAction
Txt = ActiveSheet.Shapes(.Caller).OnAction
Txt = Right(Txt, Len(Txt) - InStr(1, Txt, "!"))
End With
On Error GoTo 0
GetProcName = Txt
End Function

Regards,
Greg

-----Original Message-----
Perhaps this:

Sub GetProcedureName()
Dim Msg As String, Style As Integer, Title As String

'If calling from a commandbar control:
Title = Application.CommandBars.ActionControl.OnAction
'If calling from a worksheet based control (Forms

toolbar):
'Title = ActiveSheet.Shapes(Application.Caller).OnAction
Title = Right(Title, Len(Title) - InStr(1, Title, "!"))
Msg = "The rain in Spain falls mainly on the plain. "
Style = vbInformation
MsgBox Msg, Style, Title

End Sub

Regards,
Greg

-----Original Message-----
In all the macros I write, I put the name of the macro in
the title bar of all Msgbox and Inputbox msgs I

generate.
Is there a VBA statement that will fetch the name of the
macro that is executing so I don't have to hard code the
macro name into my msgs? I want something like the code
that fetches the worksheet name that is currently active.
.

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Incremental number for a fetching data The Ron Excel Worksheet Functions 1 November 9th 07 07:21 PM
Hide Macro's in Toolbar / Macro's list sparx Excel Discussion (Misc queries) 2 May 6th 06 08:53 PM
Fetching data from another worksheet c2k2 New Users to Excel 4 February 17th 06 04:57 PM
Fetching data from other sheets Palendromedary Excel Discussion (Misc queries) 3 December 21st 05 02:22 PM
Problem while fetching Excel records? Biju Excel Programming 3 November 6th 03 02:34 PM


All times are GMT +1. The time now is 09:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"