Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Double space after period, except when...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JayneBartram@googlemail.com - 12 Nov 2007 18:48 GMT
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
Doug Robbins - Word MVP - 12 Nov 2007 19:35 GMT
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.

Signature

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

> Hi, I've been using this really helpful macro offered by Allen Wyatt
> on his "Word tips" web page.
[quoted text clipped - 24 lines]
> Regards,
> Jayne Bartram
JayneBartram@googlemail.com - 14 Nov 2007 18:14 GMT
On 12 Nov, 19:35, "Doug Robbins - Word MVP" <d...@REMOVECAPSmvps.org>
wrote:
> Replacing this line of the code
>
[quoted text clipped - 28 lines]
>
> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.