Hi,
somewhat revised an updated,
Excluding columnbreak, which is chr(14),
and text wrapping break, which is chr(11).
Sub Test012X()
Dim lBrk As Long ' kind of break
Dim rDcm As Range ' the documents range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = Chr(12)
While .Execute
rDcm.Select ' for testing, remove later
Stop ' for testing, remove later
lBrk = KindofBreak12(rDcm)
Select Case lBrk
Case 0:
rDcm.Characters.Last.Previous = ""
Case 2, 3, 4:
rDcm.Characters.Last.Previous.InsertBreak _
Type:=wdPageBreak
End Select
rDcm.Collapse Direction:=wdCollapseEnd
Wend
End With
End Sub
Public Function KindofBreak12(ByVal rTmp As Range) As Long
Dim lSct1 As Long ' counter for sections
Dim lSct2 As Long ' counter for sections
rTmp.start = ActiveDocument.Range.start
lSct1 = rTmp.Sections.Count ' count sections
rTmp.End = rTmp.End + 1 ' extend range
lSct2 = rTmp.Sections.Count ' count sections again
If lSct1 = lSct2 Then ' next caracter is in the same section
KindofBreak12 = -1 ' ordinary pagebreak
Else
KindofBreak12 =
ActiveDocument.Sections(lSct2).PageSetup.SectionStart
End If
'wdSectionContinuous ' 0
'wdSectionNewPage ' 2
'wdSectionEvenPage ' 3
'wdSectionOddPage '4
End Function
HTH
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"