Re: Distinguishing hard spaces from regular spaces
- From: "Jay Freedman" <jay.freedman@xxxxxxxxxxx>
- Date: Tue, 19 Sep 2006 16:20:10 -0400
Hi John,
Just change to .MatchWildcards = True.
A wildcard search using a space character in the Find.Text expression won't
match a nonbreaking space. Everything else remains the same. See
http://www.gmayor.com/replace_using_wildcards.htm for more about wildcards.
The article does note that wildcard searches are case-sensitive, but this
little tidbit is missing.
A warning to anyone who's about to suggest using a wildcard Find.Text
expression of " ([;:\!\?]) to catch all the punctuation in one execution,
and a Replacement.Text expression of " \1" -- I tried it, and it doesn't
work. There's a bug that reverses the replacement when you use the \1 code,
so space+punctuation is replaced by punctuation+nonbreaking space. I first
ran into that bug in Word 2007 Beta 1, but it's also in Word 2003 and
probably earlier versions.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
John Doue wrote:
Hi,
Since in French, characters (;:?!) need an unbreakable space before
them, I frequnetly run a routine like this one for each of them:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " ;"
.Replacement.Text = "^s;"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.Mat chWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
which gets the job done.
However, I was recently remarked by a fellow translator that the
revised translations I was returning to him (with track changes on
screen) showed that all the properly hardspaced characters he had
inserted had been replaced by ... properly hardspaced characters.
Looking into the issue, I realized (I had forgotten about this) that
Word considers a "hard space" also as a "space" ... and therefore, my
macro needlessly replaces them. Which shows on screen when tracking
changes in on while running the macro.
Any ideas how to work around this?
Best regards
.
- Follow-Ups:
- Re: Distinguishing hard spaces from regular spaces
- From: John Doue
- Re: Distinguishing hard spaces from regular spaces
- References:
- Distinguishing hard spaces from regular spaces
- From: John Doue
- Distinguishing hard spaces from regular spaces
- Prev by Date: Re: list of all words meeting a woldcard criteria
- Next by Date: Re: RecordCount Returning the wrong value
- Previous by thread: Distinguishing hard spaces from regular spaces
- Next by thread: Re: Distinguishing hard spaces from regular spaces
- Index(es):
Relevant Pages
|