Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default How to Programatically Invoke "Debug"

Excellent.

Many thanks.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I invoke running a macro from within an "IF" function. ron Excel Worksheet Functions 11 February 8th 06 03:35 PM
invoke "Save Changes?" prompt I Believe Excel Programming 2 December 25th 05 12:07 PM
How to handle "Invalid Worksheet Name" error programatically in VB Jimmy Jose Excel Programming 1 December 9th 05 12:58 PM
Debug.Print "Test " vbCodeLineNumber & ": " & varName TommySzalapski[_32_] Excel Programming 1 August 2nd 05 05:17 PM
debug.print range "full" address Patti[_2_] Excel Programming 5 July 6th 05 09:27 PM


All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"