Run Mode, Design Mode, and Break Mode
The VBA IDE can be in any one of three modes: run mode, break mode, or design mode. The IDE is in design mode when you are writing code or designing a form.
Run mode occurs when a procedure is running. To run (or execute) a procedure, just place the cursor anywhere within the procedure code and hit the F5 key (or select Run from the Run menu). If a running procedure seems to be hanging, you can usually stop the procedure by hitting Ctrl-Break (hold down the Control key and hit the Break key).
Break mode is entered when a running procedure stops because of either an error in the code or a deliberate act on your part (described later in this chapter). In particular, if an error occurs, Word will stop execution and display an error dialog box with an error message, an example of which is shown in Figure 4-2.

Figure 4-2. An error message
Error dialog boxes offer a few options: end the procedure, get help (such as it may be) with the problem, or enter break mode to debug the code. In the latter case, Word will stop execution of the procedure at the offending code and highlight that code in yellow. (I discuss the process of debugging code in the “Debugging” section later in this chapter.)
Aside from encountering an error, there are several ways we can deliberately enter break mode for debugging purposes:
Hit Ctrl-Break and choose Debug from the resulting ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access