G
Guest
I am seeking to execute the following Microsoft Word 2003 find/replace macro
(Windows XP Pro SP2) – but only for a block of text that has been selected.
At present, the macro executes upon the entire document. How can I constrain
its execution to only selected text?
Thank you for your assistance.
Sub Macro()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^13 {1,}"
.Replacement.Text = "^13"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
(Windows XP Pro SP2) – but only for a block of text that has been selected.
At present, the macro executes upon the entire document. How can I constrain
its execution to only selected text?
Thank you for your assistance.
Sub Macro()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^13 {1,}"
.Replacement.Text = "^13"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub