Set breakpoint in VBA code programmatically

I have a very large piece of code written in VBA (> 50,000 lines - numerous modules). There is one interesting array for me, and I would like to find all the conditions under which the value of any element of this array changes. Values ​​can change in any module. Running a script line by line is not the most efficient option due to the size of the code.

I am looking for the best ways to solve this problem. Two ways that come to my mind are to programmatically set a breakpoint (which I'm not sure what can be done) or programmatically insert an if block after each assignment, which somehow warns me that the value has changed. (Not recommended).

So my question comes down to the following:

  • Is it possible to programmatically set breakpoints in VBA code?
  • If the answer to the above question is No , what is an effective way to solve this problem?

UPDATE: Thanks for the comments / answers. As I meant, I am interested in the smallest modification of the current code (i.e., the insertion of if-blocks, etc.) and the one most interested in the idea of ​​breaking. I would like to know if this can be done.

+5
source share
3 answers

Use the STOP keyword to break te code if a certain condition is true.

+12
source

NB: I know this is an old topic, but it can help others.

You can use the clock:

Right-click on the variables that you want to track → Add hours ... In Watch mode: “Break when the value changes”

, ( "" )

+4

in the hope that someone can take advantage of this: In such situations, regardless of the programming language used - writing a few lines of code in Perl, AWK or even shell scripts, you can solve the problem: find a regular expression containing the name of the array (ignoring case). After you export all the modules and classes in the Workbook (books) to the specified directory, scripts can search for them for you.

+1
source

All Articles