Microsoft Office Tutorials and References
In Depth Information
Other Uses for the Immediate Window
You have already seen how to use the Debug.Print statement to display information in the
Immediate window. This window has other uses as well. When a macro is in break mode, the
Immediate window has the same scope as the current procedure. You can change the value of a
variable by simply typing the new value in the Immediate window. For example, if the current procedure
has a variable Count , then by typing
Count = 100
in the Immediate window (on its own line) and pressing Enter you assign the new value to the
variable. When you continue program execution you can see the effects of the new value.
n Step Over (Shift+F8): Executes the next statement then pauses in break mode. If the
next statement is a procedure call, executes the entire procedure then pauses after exiting
the procedure. This command has the same effect as Step Into if the next statement is not
a procedure call.
n Step Out (Ctrl+Shift+F8): Executes to the end of the current procedure, then pauses in
break mode.
n Run to Cursor (Ctrl+F8): Executes to the line of code containing the cursor, then
pauses in break mode.
The Step Into and Run to Cursor commands are available even when you are not in break mode.
By using one of these commands to start the macro, rather than the usual Run Sub/User Form
command (or pressing F5), you can start the project and run it one line at a time, or up to the cursor.
What’s Next?
This chapter has just scratched the surface of Outlook macros and VBA programming. Here’s a
brief look at what’s coming up. The next three chapters deal with macros and VBA programming in
more detail:
n Chapter 23 deals with the VBA language and how it is used to write macros. You need an
understanding of VBA structure and syntax before you can proceed.
n Chapter 24 explores the Outlook Object Model, which provides the VBA programmer
with a rich set of objects that represent various elements in Outlook, such as messages,
contacts, and tasks. Macro programming is mostly a matter of manipulating these objects
to accomplish your task.
n Chapter 25 walks you through some complete, real-world examples of Outlook macros.
Search JabSto ::

Custom Search