How to Programatically Invoke "Debug"
Is there a way to halt the execution of a program or macro and invoke
debug via the code? Regards Greg |
How to Programatically Invoke "Debug"
Use Stop.
If sInput = "No" Then Stop John Green Sydney Australia "Greg Glynn" wrote in message oups.com... Is there a way to halt the execution of a program or macro and invoke debug via the code? Regards Greg |
How to Programatically Invoke "Debug"
Greg,
You can use either Stop Debug.Assert False 'Or some condition like Debug.Assert MyBoolean As these are in code, they remain between close/open of the file. Setting break points (left click, level with an executable line of code) on the left border of the code pane, so you get the line highlighted (the default colour being red). Breakpoints a removed when the file is closed. NickHK "Greg Glynn" wrote in message oups.com... Is there a way to halt the execution of a program or macro and invoke debug via the code? Regards Greg |
How to Programatically Invoke "Debug"
Greg,
You can use the Stop statement. This will pause the code and bring up the VBA Editor. Better yet is Debug.Assert (Condition) where Condition is any VBA expression that returns True (or any non-zero result) or False (or 0). If Condition is True or not equal to 0, Debug.Assert does nothing. If Condition is False (or 0), execution will pause on that line of code and open the VBA Editor. The advantage of Debug.Assert is that the break is conditional -- you can cause the code to break on Debug.Assert under only specific conditions, such as a variable being uninitialized. Stop is not conditional. It will always pause the code. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Greg Glynn" wrote in message oups.com... Is there a way to halt the execution of a program or macro and invoke debug via the code? Regards Greg |
How to Programatically Invoke "Debug"
Excellent.
Many thanks. |
All times are GMT +1. The time now is 04:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com