How to List Procedures Called by Other Procedures in Excel VBA
Question details
The user wants to identify calling procedures, called procedures, and destination modules across a VBA project containing multiple modules.

- Product
- Excel VBA
- Device & OS
- not provided
- Scenario
- Mapping dependencies and identifying procedure calls across various modules within an extensive VBA project.
- Observed behavior
- The VBA Extensibility library does not offer a native runtime dependency API, requiring users to rely on static text analysis to find procedure calls.
Before analyzing your code programmatically, ensure you have navigated to your macro security settings and enabled 'Trust access to the VBA project object model' to prevent permission errors.
Perform Static Text Analysis using the VBA Extensibility Library
Use the VBA Extensibility library to programmatically read the source code text in your modules and use string matching to map procedure dependencies.
Since VBA lacks a built-in runtime execution tracker for procedure dependencies, you can iterate through the project components statically. By extracting the text of each module, you can search for occurrences of your procedure names to determine where they are being called.
Open Excel, go to the Developer tab, click 'Macro Security', and check 'Trust access to the VBA project object model' under Developer Macro Settings.
Press Alt + F11 to open the Visual Basic Editor. Click 'Tools' > 'References', then find and check 'Microsoft Visual Basic for Applications Extensibility 5.3'.
Write a VBA script that loops through 'ThisWorkbook.VBProject.VBComponents' to access the CodeModule object of each standard module, class, or userform.
Use the 'CodeModule.Lines' property to extract the source code text line by line. Apply string matching functions like 'InStr' or regular expressions to search for specific procedure names and record the module where the call is found.

Analyze and Manage VBA Macros with WPS Office
WPS Office provides excellent support for VBA macros and developer tools. You can seamlessly run Extensibility scripts to map procedure dependencies within a fast and familiar environment.
- 1. Download and Install WPS Office: Get the latest version of WPS Office from the official website and complete the installation.
- 2. Open Your Macro Workbook: Launch WPS Spreadsheet and open your .xlsm or .xlsb workbook containing the complex VBA project.
- 3. Access the Developer Tools: Navigate to the Developer tab on the ribbon and click the 'Visual Basic' or 'Macro' icon to open the integrated code editor.
- 4. Run Analysis Scripts: Insert your dependency mapping script into a new module and execute it to extract the procedure calling hierarchy.

Frequently Asked Questions
Why is string matching considered expensive in large VBA projects?
String matching requires reading every line of code across all modules and comparing it against a list of all known procedure names. In massive projects, this iterative parsing requires significant CPU cycles, though using efficient search algorithms or regular expressions can mitigate the delay.
Can I track runtime procedure calls dynamically instead of using static analysis?
VBA does not natively expose a runtime call stack API for programmatic logging. To track execution dynamically, you must manually insert logging code (like 'Debug.Print' or writing to a log file) at the beginning of each procedure.
What happens if a procedure name is used as a variable or string literal?
Basic static string matching (using InStr) might yield false positives by identifying variables, comments, or string literals that happen to share the same name as a procedure. Using regular expressions to isolate exact procedure call syntax or ignoring commented lines is recommended to improve accuracy.




