View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Ed
 
Posts: n/a
Default Macro: Execute for Selected Text Only

Try this: Just after Sub Macro(), add the following lines:
Dim myRange as Range
Set myRange = Selection.Range

Then, is every line of your macro, replace "Selection" with "myRange"
(without any quote marks).

Give that a shot and see if it works for you.

Ed

"Pleonasm" wrote in message
...
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