You would have to turn on wildcards and in place of [two spaces] and [one
space], you were intended to insert the appropriate number of spaces using
the space bar. After all, that was the whole point of the exercise.
Hi.
Responding to your (faintly patronizing ... faintly sarcastic ... <g>)
message, thanks for this. I'm a dunce when it comes to vb, this
proves it yet again <g>.
This made me laugh this morning, I'm sorry. One has to laugh at my
mistake. Didn't even realize I was doing it, of course.
With ActiveDocument.Range.Find
.Execute findText:="([A-Z]{1}.) ([A-Z]{1})",
MatchWildcards:=True,
_
ReplaceWith:="\1 \2", Replace:=wdReplaceAll
End With
It is probably my fault in not explaining properly, but what is
happening is that I'm still left with 2 spaces after the second
initial. For over half hour I've tried and tried to fix this but I
don't know how.
The macro seems to work just great for the first part. It replaced
the 2 spaces with none between the repeating 2 initials throughout the
document (I modified it from "\1 \2" above to "\1\2"). I never
considered that the 2 initials might be a different issue from one.
My mistake. Well, at any rate, this is what happens:
A.[2 spaces]B.[2 spaces]Someone (see, I learn ... <g>)
A.B.[2 spaces]Someone
Did searches on vbe and archives for wildcards and syntax or
parameters, or whatever we're talking about here would be called, but
nothing came up.
Ideally, of course, one would need to keep the double spaces between
sentences but have only one space after all initials and no spaces
between the initials themselves, no matter how many there would be.
So, pls bear with me, hoping someone here could help fix this final
step.
Seriously, not all of us who post in these ngs have any real expertise
to speak of so what is obvious to you all, is not to us. Appreciate
the help very much said:
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
On Sat, 24 Mar 2007 17:09:14 +0100, "Doug Robbins - Word MVP"
Use a wildcard replace with
([A-Z]{1}.)[two spaces]([A-Z]{1})
for find what and
\1[one space]\2
for the replace with.
I bet I've done something wrong!
I tried the above in this:
Sub INITIALS_fixSpacesAfter()
With ActiveDocument.Range.Find
.Execute FindText:="([A-Z]{1}.)[two spaces]([A-Z]{1})",
ReplaceWith:="\1[one space]\2", Replace:=wdReplaceAll
End With
End Sub
Nothing seems to happen and the changes aren't made. what am I doing
wrong, pls? <g>
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
Last one today, I PROMISE <g>.
I've had the situation come up in my clean-up macros that after
putting correct spaces after each line, that the script interprets
initials in the same way.
Trying to use my newfound knowledge, I tried this below:
-----------------------------------------------------------------------
Sub RemoveSpaceInInitials()
With ActiveDocument.Range.Find
.Execute FindText:=" ^?. ", ReplaceWith:=" ^?. ",
Replace:=wdReplaceAll
End With
End Sub
-----------------------------------------------------------------------
But both the macro and when done manually in the dialogue box don't
recognize the ^? in the replace box. What is the best way to do this,
then, pls? Thankx much.