Run-Time Tools

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The Microsoft® Visual Basic® for Applications (VBA) run-time debugging tools are designed to give you a snapshot of what is happening in your code at any point. You use these tools together to let you take a closer look at what your code is doing at any point in time. The following table contains a list of all the tools available to you and a short description of when they are useful.

Tool Description
Breakpoints Breakpoints let you stop program execution on any line of executable code. When execution has stopped, you can use one or more of the other available tools to investigate your code. A breakpoint will stop your code on the line of code that will be executed next. When your code encounters a breakpoint, it is in break mode and remains in break mode until you press F5 to continue execution.
Step modes You can use the four step modes to start execution of a subroutine or to continue execution after it has stopped at a breakpoint. The four available modes are Step Into, Step Over, Step Out, and Run To Cursor. Using any of these modes to step through code does not take the code out of break mode.
Watch expressions Watch expressions let you monitor the value of any variable, property, object, or expression as your code executes. They also let you specify that your code should enter break mode upon some condition; for example, if an expression is true or if the value of a variable changes. If you do not have to continually monitor a value, you can use the Quick Watch dialog box to quickly check the value of a variable or expression.
Immediate window This window is an extremely versatile tool that you should be using constantly to debug and test your code. All Debug.Print statements are output to the Immediate window. When your code is in break mode, the Immediate window has the same scope as the procedure in which the breakpoint is located. This makes it possible for you to test and change the value of variables. In addition, you can use the Immediate window to call procedures and test them by using different data without having to run your application from the beginning.
Locals window This extremely powerful and often overlooked tool provides a snapshot view of the values of all variables, constants, objects, and properties of objects currently in scope when code is in break mode.
Call stack This stack contains a list of all active procedures when code is in break mode. This list can help you trace the execution of your code and highlight the possible location of errors in currently active procedures.

For more information about any of the debugging tools, search the Visual Basic for Applications Reference Help index for the name of the specific tool.

See Also

Writing Error-Free Code | Design-Time Tools | Script Debugging Tools | Additional Debugging Techniques | Handling Errors