G
Guest
Office Pro 2003
The following code works well but I am too much a novice to do it efficiently.
The code finds Soft Return, Hard Return, vbLf and three spaces for two
(Normally there are two spaces after a period. The code below makes three
spaces 2+1. Therefore, I must reset three with two)
Sub FindReplaceHardSoftReturn()
With Selection.Find
.Text = vbLf 'Line Feed Chr(10)
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = "^l" 'Soft Return Chr(11)
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = "^p" 'Hard Return Chr(13)
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = " " 'Three spaces replaced with two
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
End Sub
Any thoughts would be helpful.
Dennis
The following code works well but I am too much a novice to do it efficiently.
The code finds Soft Return, Hard Return, vbLf and three spaces for two
(Normally there are two spaces after a period. The code below makes three
spaces 2+1. Therefore, I must reset three with two)
Sub FindReplaceHardSoftReturn()
With Selection.Find
.Text = vbLf 'Line Feed Chr(10)
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = "^l" 'Soft Return Chr(11)
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = "^p" 'Hard Return Chr(13)
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
With Selection.Find
.Text = " " 'Three spaces replaced with two
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
End Sub
Any thoughts would be helpful.
Dennis