VBA in MS Word affects whole document, not just selection -
i want have vba script perform find / replace in selection , assign macro button on quick access toolbar, save having click through usual find/replace procedure.
i recorded macro while doing , get:
sub findreplace() ' ' findreplace macro ' ' selection.find.clearformatting selection.find.replacement.clearformatting selection.find .text = "^p" .replacement.text = " " .forward = true .wrap = wdfindask .format = false .matchcase = false .matchwholeword = false .matchwildcards = false .matchsoundslike = false .matchallwordforms = false end selection.find.execute replace:=wdreplaceall end sub
but when run macro on selection change paragraph marks spaces continues on change whole document, not selection.
i'm no stranger vba can't see how fix stops when selection done.
you going need use
.wrap = wdfindstop
instead of
.wrap = wdfindask
Comments
Post a Comment