G
gvm
I have a macro which reformats selected text and then surrounds it with
quotation marks. To use the macro, I first mark the text to be reformatted by
selecting it with the mouse. Things are not quite perfect because when I mark
the text, Microsoft in its usual helpful way, presumes to include a space
character at the end of the last word. I don't want a superfluous space
character at the end of the block and it is nigh impossible to over-ride the
way Word anticipates (incorrectly) the text I want to mark. Rather than make
the selection process awkward, it is probably better to include a statement
in the macro that deletes the superfluous space character. The macro follows,
TIA ... Greg
Sub Overwrite_linebreaks()
' Keyboard Shortcut Ctrl + F10
With Selection
If .Type = wdSelectionIP Then Exit Sub
With .Font
.Name = "Times New Roman"
.Size = 12
.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 = wdColorBlue
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
.InsertBefore """"
.InsertAfter """" & vbCr
'..InsertAfter Chr(34) & vbCr
.Collapse wdCollapseEnd
End With
End Sub
quotation marks. To use the macro, I first mark the text to be reformatted by
selecting it with the mouse. Things are not quite perfect because when I mark
the text, Microsoft in its usual helpful way, presumes to include a space
character at the end of the last word. I don't want a superfluous space
character at the end of the block and it is nigh impossible to over-ride the
way Word anticipates (incorrectly) the text I want to mark. Rather than make
the selection process awkward, it is probably better to include a statement
in the macro that deletes the superfluous space character. The macro follows,
TIA ... Greg
Sub Overwrite_linebreaks()
' Keyboard Shortcut Ctrl + F10
With Selection
If .Type = wdSelectionIP Then Exit Sub
With .Font
.Name = "Times New Roman"
.Size = 12
.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 = wdColorBlue
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
.InsertBefore """"
.InsertAfter """" & vbCr
'..InsertAfter Chr(34) & vbCr
.Collapse wdCollapseEnd
End With
End Sub