Datasheet
Simple Macro Edits That Don’t Require a Ph.D. in VBA
566
✦ Remove extraneous commands. If you inadvertently used a command
while recording a macro, you can clean up your macro by removing the
unnecessary command.
✦ Remove unwanted dialog box settings. If you record a dialog box in a
macro, Word includes every setting in the dialog box. You can remove
the settings that you do NOT WANT the macro to change. For example, if
you use Font dialog box to format text with small caps, Word inserts the
following commands into the macro:
With Selection.Font
.Name = “Times New Roman”
.Size = 9.5
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.strikethrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = True
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0.3
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
This command looks complicated at first, but if you study it, you see
that it is little more than a list of all the dialog box controls that appear
in the Font dialog box. The periods look strange appearing in front of
each command argument as they do, but they’re required. You can
safely delete the lines that specify those dialog box controls you don’t
want to use so that the resulting command looks like this:
With Selection.Font
.SmallCaps = True
End With
50_040584 bk09ch01.qxp 12/28/06 9:28 PM Page 566