I created Macro for replacing multiple characters at once. If I apply it for the whole document and then paste another text into the same document, applying the same Macro will do fine for newly pasted text, but will mess up rest of the text unto which Macro was already applied.

I was thinking problem would be solved if Macro could be applied only for selected text, leaving the rest of the document untouched.

Help, anyone?

Regards, Tom

  • Can you show the source code of your macro? The solution may depends on how do you work with selection object in the macro. Dec 8, 2017 at 12:28
  • This is the code: textuploader.com/dq37a Thanks! Dec 8, 2017 at 13:12

2 Answers 2


Change .Wrap = wdFindContinue to .Wrap = wdFindStop in your macro:

' Macro1 Macro
    With Selection.Find
        .Text = "ä"
        .Replacement.Text = ChrW(257)
        .Forward = True
        .Wrap = wdFindContinue
  • It's working only when I select the text. But if text is not selected (mouse cursor blinking) then it applys for whole document starting from the point where the mouse cursor is (no text selected) Dec 8, 2017 at 13:19
  • Did not you mean, "I was thinking problem would be solved if Macro could be applied only for selected text" ? Dec 8, 2017 at 13:20
  • well... it would, but a little upgrade would be nice :) Dec 8, 2017 at 13:22
  • This solved a situation for me where a recorded macro (search and replaces) which was supposed to apply to selected text was being applied to the whole document incorrectly. I found .Wrap = wdFindAsk and changed to .Wrap = wdFindStop and it worked perfectly after that.
    – Jimbo
    Mar 15, 2022 at 19:07

Works well for me for the selection only (replacing Enters with whitespace symbol):

Sub RemoveEntersForSelectedText()
    With Selection.Find
    .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
End Sub

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .