Consulting

Results 1 to 5 of 5

Thread: Build a tree of called functions / procedures

  1. #1
    VBAX Tutor
    Joined
    Mar 2010
    Posts
    287
    Location

    Question Build a tree of called functions / procedures

    Hi...I would like to build a full tree of called function / procedures starting with the workbook auto_open event. For each new function / procedure found it should keep linking to further calls from those functions / procedures.

    Is there anything available to do this? I looked at MZ-Tools but this only allows you to find where a single item is called from, I want to build a full list / map of all calls.

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Have you looked at Excel's Auditing tools, like Trace Dependents and Trace Precedents?

  3. #3
    VBAX Tutor
    Joined
    Mar 2010
    Posts
    287
    Location

    Question

    I thought that only worked with workbook objects etc?

    If I selected the workbook open event and searched all dependents it would find it to the most granular level?

    Sub 1 > Function 1 > Function 2 > Sub 4 > Function 3 etc

    Thanks

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    I thought that you were refering to worksheet functions.

  5. #5
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    What is the purpose of this?

    One could write a routine that adds a "write this procedure's name to the record sheet" instruction to the beginning of each Sub or Function. (a "shift column of record sheet" instruction would be needed before each End Sub or Exit Sub.)

    But that would only record the path that a particular running of the sub(s).
    It would (probably) miss Macro2 in this kind of situation.
    [vba]If x = 1.24287 Then
    Call Macro2
    Else
    Call Macro3
    End If[/vba]

    Alternately, one could write a routine that parsed the VBA text. But, writing a compiler in the language being compiled is usually a futile business.

    If the code is properly structured, a map like this isn't needed.

    I'm old school enough that when my code gets large enough and complicated enough to need this kind of treatment, a print-out and a pencil are the most valuable approach.

Posting Permissions

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