>

Using the Calls Dialog Box to Trace Nested Procedures

The Calls dialog box displays a list of all active procedure calls. Active procedure calls are the procedures that have started but haven't finished executing. For example, you can use the Calls dialog box to trace the procedure calls in the following code.


Sub Demo1()
    Call Demo2
End Sub

Sub Demo2()
    Call Demo3
End Sub

Sub Demo3()
    MsgBox "Demo3 is running"
    Stop
End Sub

The Calls dialog box lists three active procedure calls when execution is suspended by the Stop statement in the Demo3 procedure.

To display the Calls dialog box

The Calls dialog box is especially helpful if you want to trace nested procedures. For example, a procedure can call a second procedure, which can call a third procedure — all before the procedure that started this chain has finished executing. In the preceding illustration, the Demo1 procedure called the Demo2 procedure, which called the Demo3 procedure.

The Calls dialog box lists all the active procedure calls in a series of nested procedure calls. It places the most recently started procedure call at the top of the list; earlier procedure calls appear in order below that. The information given for each procedure includes the name of the workbook and module that contains the procedure, followed by the name of the procedure.

You can click Show to display the statement that calls the next procedure listed in the Calls dialog box.

To display the statement that calls the next procedure in the Calls dialog box

1. In the Calls dialog box, click the procedure call you want to display.

2. Click Show.

Visual Basic displays the procedure in the module. The insertion point indicates the statement that calls the next procedure in the Calls dialog box (the procedure above the displayed procedure).

If you click the current (top) procedure in the Calls dialog box and then click Show, Visual Basic displays the current statement (the statement at which execution is suspended).