+ Reply to Thread
Results 1 to 2 of 2

VBA: test for top of call stack

  1. #1
    Registered User
    Join Date
    06-03-2013
    Location
    Europe
    MS-Off Ver
    Excel 2003
    Posts
    1

    VBA: test for top of call stack

    Hello,

    I would like to test if a procedure is called directly by the user (so it is on top of the call stack, see ctrl+L in debug mode) or called from another procedure.

    Does someone know a way to do this without tracking the call stack in a parameter passed in each procedure?

    I tried to do this using a public parameter topOfCallStackFound and then adding to each procedure some code like:

    Please Login or Register  to view this content.
    But this doesn't work because VBA remembers the value of topOfCallStackFound after code execution is finished! The lifetime of topOfCallStackFound only ends when the workbook is closed, an end command is given or in a few other not useful circumstances. If it is possible to end the lifetime of topOfCallStackFound when code execution is finished and/or reinitialize topOfCallStackFound to false when the user starts new code execution, my problem would be solved. But other solutions are of course also greatly appreciated.

    Thanks!

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA: test for top of call stack

    vba has no access to the call stack so you have to create your own-there is an example here http://etutorials.org/Microsoft+Prod...ocedure+Stack/
    or you could create your own stack class
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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