Microsoft Office Tutorials and References
In Depth Information
Assigning Macros to Shortcut Keys
Sorry, no can do. It would be a nice feature to be able to assign frequently used macros to shortcut
keys, but Outlook does not permit this.
Debugging Macros
When you create a macro, you may find that it does not do exactly what you wanted it to do. This
is called a bug and the Outlook VBA Editor provides you with some tools for finding and fixing
bugs. Generally, bugs are almost always the result of one or both of the following problems:
n A program variable takes on the wrong value.
n Program execution takes the wrong path through the macro code.
The debugging tools let you address both of these problems as follows:
n Breakpoints let you temporarily suspend the macro’s execution at specified lines of code
or when specified conditions are met.
n Watches let you examine and change the value of variables during macro execution.
n Controlling execution lets you execute a program one line at a time and control the path
execution takes.
Working with Breakpoints
When a macro is executing inside the VBA Editor, you can temporarily pause macro execution —
in other words, put the macro in break mode . You do this by setting one or more breakpoints,
which specify that the program should pause either when a specified line of code is reached or
when a certain condition is met. When a program is in break mode, the next statement to be
executed is highlighted in the editor window (if possible — the next statement may not be known),
and you can carry out various actions to help track down the cause of a bug. Then, you can
continue execution normally or terminate the program.
When in break mode, you can rest the mouse pointer over a variable name in your code and the VBA
Editor will display the current value of the variable in a small window. You can also edit your code,
with some limitations. The other tools described in this section are also available in break mode.
To enter break mode when execution reaches a certain location in your macro code, set a
breakpoint on that line. Before you start execution, or while in break mode, move the editing cursor to
the line and press F9. A line that has a breakpoint set is displayed in a different color and with a
dot in the left margin, as shown in Figure 22.8. Execution pauses just before executing the line
with the breakpoint. You can set breakpoints on as many lines as you want. Press F9 again to
remove the breakpoint from a line. Press Ctrl+Shift+F9 to remove all breakpoints.
Search JabSto ::

Custom Search