+ Reply to Thread
Results 1 to 3 of 3

Get Macro Name (while it's running).

  1. #1
    Registered User
    Join Date
    11-04-2010
    Location
    Ottawa, Ontario, Canada
    MS-Off Ver
    Excel 2002
    Posts
    13

    Question Get Macro Name (while it's running).

    Hi everyone,

    I've implemented an error system in my program (using VBA in Excel). I would like know if there's an easy way to capture the name of a running macro.

    Given that this is an error handleling system, I'd rather use excel coding to get the macro name rather than manually putting the name every time i launch a routine/function as this might lead to other errors due to typos, routine changes, etc.

    The closest I've come across is this code:

    Please Login or Register  to view this content.
    Any thoughts on how I could get the name of the macro ???

    Any help is apprecited.
    Last edited by CEC; 10-05-2011 at 08:45 AM. Reason: Capture macro name while running

  2. #2
    Registered User
    Join Date
    11-04-2010
    Location
    Ottawa, Ontario, Canada
    MS-Off Ver
    Excel 2002
    Posts
    13

    Cool Re: Get Macro Name (while it's running).

    Update:

    I figured a workaround but it's not pretty.

    The following would give me the Object name (userform, module, class) but I still haven't figured how to grap the procedure name...

    Object capture
    Please Login or Register  to view this content.

    At the moment, I'm using 3 public variables in a module (AppRegistry). I'm stuck with the following code (inserted in every procedure for the program)...I need to replace (in this example) --> AppRegistry.ActiveProcess = "Att_Retrieve_Click()" for something more dynamic. See example below:
    Please Login or Register  to view this content.
    Hope this can help you help me...I'm desperate (it's been a day and I still haven't figured it out!).

    Thanks.
    Last edited by CEC; 10-05-2011 at 09:14 AM.

  3. #3
    Registered User
    Join Date
    11-04-2010
    Location
    Ottawa, Ontario, Canada
    MS-Off Ver
    Excel 2002
    Posts
    13

    Angry Re: Get Macro Name (while it's running).

    Nevermind, this isn't working while it's running. It appears the VBA engine simply will not recognize the module or its running macro while it's running. Although you might see the value displayed when entering debug mode, the values will not be "defined" while it's running.

    The following example will not be defined while it's running but will display a value in debug:

    i.e.
    Please Login or Register  to view this content.
    I'm giving up this project. I'll simply hardcode everything though a public variable that'll switch everytime I open/close a userform or call/run routines/functions. It's sloppy and not the way I would have done it but it looks like it's the only way.

    Feel free to prove me wrong...

    Regards,

    Alex
    Last edited by CEC; 10-12-2011 at 09:24 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1