Find & Replace checking every instance

P

Pedro Baiano

Hello guys:

I need a macro to find 2-3 spaces and replace that with one space. That is
pretty simple. My problem is that the user has to decide in each instance if
s/he wants to replace it or not. Like when you use the Find & Replace box. It
should be inside a macro as it is one of many Find & Replaces for a final
editing of a doc.

What have I done so far (it works, but does not stop in each instance):

Sub Spaces_Space()
'
' Spaces_Space Macro
' Macro recorded 05/12/2007 by /
'
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " {2,3}"
.Replacement.Text = " "
.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

Thank you,

P.
 
B

BrianWren

I would create a user form that would be presented when a decision was
required. You could put the page number on the form, and grab 3 r 4 words on
either side of the replacement point to show to the user so that he would
have the necessary details for making a decision.

Just put a Yes and a No button on the form with a prompt.

Incidentally, the generic way to refer to someone is “he,†not “s/he.†This
is an awkward construction feminists have given us as a result of the chip on
their shoulders, and an over-eager desire to “not offend.†If we all refuse
to play we will soon be rid of these inventions.
 
P

Pedro Baiano

BrianWren said:
I would create a user form that would be presented when a decision was
required. You could put the page number on the form, and grab 3 r 4 words on
either side of the replacement point to show to the user so that he would
have the necessary details for making a decision.

Just put a Yes and a No button on the form with a prompt.
Hello Brian:

Maybe I did not ask the right question -- I wanted to know if there is a
procedure to look for each instance included in VBA, instead of designing the
loop myself. Anyway, by your answer, I am assuming there is not.

As for the s/he, I do agree with you, but I do not care that much to write
one way or the other.

Thank you for your help.

P.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top