View Single Post
 
Old 03-27-2023, 03:21 AM
Harvi007 Harvi007 is offline Windows 11 Office 2019
Novice
 
Join Date: Aug 2022
Posts: 11
Harvi007 is on a distinguished road
Lightbulb Half working...

Hi,

I've had a look around and a bit of a play.

The following code seems to do what I'm looking for, but can't handle 'Page Break' and thus keeps adding 'Enter' until I end the macro.


Application.ScreenUpdating = False
Selection.HomeKey Unit:=wdStory
Do
Selection.EndKey Unit:=wdLine
If Selection.End >= ActiveDocument.Content.End - 1 Then
Exit Do
End If
If Asc(Selection) <> 13 Then
Selection.InsertParagraphAfter
End If
Selection.MoveDown Unit:=wdLine
Loop
Application.ScreenUpdating = True

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find

.Text = "^p"
.Replacement.Text = "^l"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll

End With

Please if anyone can help me get past the 'Page Break', that will help me complete my goal.

Thanks in advance,
Reply With Quote