E
Elizabeth A. Bañuelos
I am creating a macro which inserts a Filename field into a document. I want
to then resize the font of ONLY the inserted field to 7pt. Presently my
macro reads as follows:
Selection.EndKey Unit:=wdStory
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"FILENAME ", PreserveFormatting:=True
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
With Selection.Font
.Name = "Times New Roman"
.Size = 7
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
This result was fine, as long as there was nothing else on the line ahead of
the Filename field insertion, which tends to USUALLY be the case. But,
because the macro indicates to return to the beginning of the line to apply
the font size, it also modifies any other text on the same line ahead of the
inserted field. I have tried various combinations of Shift, Ctrl and Alt
along with arrow keys for selecting the field with my keyboard while
recording the macro, but no luck.
So I need to modify the macro somehow so that it only selects the inserted
field instead of returning to the beginning of the line before it sizes the
font of the inserted field.
Any help would be greatly appreciated! Thanks!
to then resize the font of ONLY the inserted field to 7pt. Presently my
macro reads as follows:
Selection.EndKey Unit:=wdStory
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"FILENAME ", PreserveFormatting:=True
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
With Selection.Font
.Name = "Times New Roman"
.Size = 7
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
This result was fine, as long as there was nothing else on the line ahead of
the Filename field insertion, which tends to USUALLY be the case. But,
because the macro indicates to return to the beginning of the line to apply
the font size, it also modifies any other text on the same line ahead of the
inserted field. I have tried various combinations of Shift, Ctrl and Alt
along with arrow keys for selecting the field with my keyboard while
recording the macro, but no luck.
So I need to modify the macro somehow so that it only selects the inserted
field instead of returning to the beginning of the line before it sizes the
font of the inserted field.
Any help would be greatly appreciated! Thanks!