I would like to be able to toggle on/off the option to enter break mode whenever my VBA code is called. The only way I know to do this is set breakpoints at all the "points of entry" into code or have literally every one of these methods call a separate function for purposes of debug.
The "points of entry" may be button clicks or worksheet events and there are a fair number of them.
For example, I could do:
Private Sub bt1Click()
callThisOnEveryMethod
'other code
End Sub
Private Sub bt2Click()
callThisOnEveryMethod
'other code
End Sub
'etc, repeat 100 times
Private Sub callThisOnEveryMethod()
'set breakpoint on this method
End Sub
This is not really ideal since I am depending on me adding that to each method and every subsequent method. I don't really trust myself to get 100% of them this way and it's a lot of clutter for debug purposes only. I can add other code here too and even wrap it in an if MY_GLOBAL_DEBUG_BOOLEAN then
type statement but I still need to add this code (or the calling method) to every method I write which could start VBA execution.
Imagine I might have 100 methods which could be the start of VBA code executing.
It is not ideal to setup and remove break points on EVERY method each time I want to do this, either, because of the number to turn on/off.
What I would like is to tell VBA somehow "whenever you start executing code, immediately break and go into debug mode regardless of breakpoints, assertions, and without requiring each method to have lots of extra code."
Is this possible?