ubu said:
How do I slow down the execution of code in VBA
without having to press F8 each time? I want to view
the code execute slowly. Is there a timer command I
can use to do this?
Hi ubu,
As Martinique said, not quite as you want.
Some alternatives:
If you keep F8 pressed, the code will be stepped through rather fast.
You could set a couple of breakpoints on lines where you want to see what's
happening.
You can do that by clicking to the left of the line, or with F9; a red
bullet should appear.
Then use F5 to run the code up to the next breakpoint.
You can put the cursor in some line, and use Ctrl+F8 to run all the lines
up to that point.
If you have subroutines or functions that you don't want to step through,
you can use Shift+F8.
If you are interested in some variable, you can add a "watch" for it, and
make the code stop for example each time after the variable changes
(right-click on it somewhere in the code and choose "Add watch...", and in
the dialog check the corresponding check box).
Or you could create a dummy Boolean variable, and make the code stop when
the variable is "True".
You could use that for example to make the code stop when the Selection is
collapsed:
Dim boolDebug as Boolean
' ...
boolDebug=(Selection.End=Selection.Start)
Then add a watch for boolDebug that stops the code when boolDebug is
"True".
Greetings,
Klaus