PDA

View Full Version : Build a tree of called functions / procedures



theta
08-01-2012, 02:37 AM
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.

mikerickson
08-01-2012, 07:45 AM
Have you looked at Excel's Auditing tools, like Trace Dependents and Trace Precedents?

theta
08-01-2012, 08:14 AM
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

mikerickson
08-03-2012, 07:51 AM
I thought that you were refering to worksheet functions.

mikerickson
08-03-2012, 07:57 PM
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.
If x = 1.24287 Then
Call Macro2
Else
Call Macro3
End If

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.