|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon Nov 12, 2007 6:48 pm Post subject: Double space after period, except when... |
|
|
Hi, I've been using this really helpful macro offered by Allen Wyatt
on his "Word tips" web page.
Sub TwoSpaces()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([.\?\!]) {1,}"
.Replacement.Text = "\1 "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
It replaces any number of spaces after a period with 2 spaces, as
required by my UK organisation.
What it doesn't do is add 2 spaces after a period if there is
currently no space after said period.
This punctuation error occurs often here, so please can anyone tell me
how the above macro can be modified to take care of this extra
problem, if possible?
Regards,
Jayne Bartram |
|
| Back to top |
|
 |
Google Sponsor

|
Posted: Mon Nov 12, 2007 6:48 pm Post subject: Advertisement |
|
|
|
|
| Back to top |
|
 |
Doug Robbins - Word MVP Guest
|
Posted: Mon Nov 12, 2007 7:35 pm Post subject: Re: Double space after period, except when... |
|
|
Replacing this line of the code
..Text = "([.\?\!]) {1,}"
with
..Text = "([.\?\!])"
would cause two spaces to be inserted after any . ? or !
That code should be run first, so that if there are already spaces there,
running the second code will reduce the number of them to two.
BUT, if there are decimal numbers in your document you would end up with two
spaces after the decimal point. To fix that, you would then need to use
". ([0-9]{1,})"
and replace with
".\1"
to remove those two spaces. Note there are two spaces between the . and the
( above.
--
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
<JayneBartram@googlemail.com> wrote in message
news:1194893308.007569.118300@v3g2000hsg.googlegroups.com...
| Quote: | Hi, I've been using this really helpful macro offered by Allen Wyatt
on his "Word tips" web page.
Sub TwoSpaces()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([.\?\!]) {1,}"
.Replacement.Text = "\1 "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
It replaces any number of spaces after a period with 2 spaces, as
required by my UK organisation.
What it doesn't do is add 2 spaces after a period if there is
currently no space after said period.
This punctuation error occurs often here, so please can anyone tell me
how the above macro can be modified to take care of this extra
problem, if possible?
Regards,
Jayne Bartram
|
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Nov 14, 2007 6:14 pm Post subject: Re: Double space after period, except when... |
|
|
On 12 Nov, 19:35, "Doug Robbins - Word MVP" <d...@REMOVECAPSmvps.org>
wrote:
| Quote: | Replacing this line of the code
.Text = "([.\?\!]) {1,}"
with
.Text = "([.\?\!])"
would cause two spaces to be inserted after any . ? or !
That code should be run first, so that if there are already spaces there,
running the second code will reduce the number of them to two.
BUT, if there are decimal numbers in your document you would end up with two
spaces after the decimal point. To fix that, you would then need to use
". ([0-9]{1,})"
and replace with
".\1"
to remove those two spaces. Note there are two spaces between the . and the
( above.
--
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
|
Thanks so much, that's a big help. I 'll have a go at including your
suggested code.
Regards,
Jayne Bartram |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|