Datasheet

536
delete the lines that specify the dialog box controls you don’t want to
use so that the resulting command looks like this:
With Selection.Font
.SmallCaps = True
End With
With a little more VBA knowledge, you can also remove the With and
End With commands and substitute just the following line:
Selection.Font.SmallCaps = True
Using Auto Macros
An auto macro runs automatically whenever a key event happens, such as
when Word starts or a document closes. Word recognizes auto macros by
name. For example, a macro named AutoNew automatically runs when you
create a new document from a template, and a macro named AutoClose
automatically runs when you close a document.
To create an auto macro, you simply create a macro by using one of these
special macro names:
AutoExec: Runs when Word starts. Store it in the Normal.dotm
template.
AutoExit: Runs when Word exits. Store it in the Normal.dotm template.
AutoNew: Runs whenever a new document is created by using the tem-
plate that contains the AutoNew macro.
AutoOpen: Runs whenever an existing document opens. You can create
an AutoOpen macro in the Normal.dotm template or in the template
that’s attached to the document or both.
AutoClose: Runs whenever an open document closes. This macro can
reside in Normal.dotm or in the template attached to the document.
You can prevent any auto macro from executing by holding down the Shift
key while performing the action that otherwise triggers the macro. For exam-
ple, holding down the Shift key while creating a new document prevents the
AutoNew macro from running.
Using Auto Macros
50_487662-bk09ch01.indd 53650_487662-bk09ch01.indd 536 4/15/10 9:18 PM4/15/10 9:18 PM