Thread: [Solved] Help required with spacing
View Single Post
 
Old 08-10-2011, 11:24 PM
rohanmalhotra rohanmalhotra is offline Windows XP Office 2003
Novice
 
Join Date: Aug 2011
Posts: 3
rohanmalhotra is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
Try:

Sub TwoSpacesAfterSentence()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.MatchWildcards = True
.Text = "(*{2})([.\!\?]) ([A-Z])"
.Replacement.Text = "\1\2 \3" 'Two spaces between 2 and \
.Execute Replace:=wdReplaceAll
.Text = "([.\!\?]) {3,}([A-Z])"
.Replacement.Text = "\1 \2"
.Execute Replace:=wdReplaceAll
'This should prevent most cases of improper double spacing
'in names (e.g., F. Lee Bailey, George W. Bush, etc.)
.Text = "([!A-Z][A-Z].) ([A-Z])" 'Two spaces between ) and (
.Replacement.Text = "\1 \2"
.Execute Replace:=wdReplaceAll
End With
End Sub
Thanks for your help.
however, it is still not working. what it does is that it deletes spaces after all periods in the document.
Reply With Quote