Helmut
Fri Sep 08 14:05:21 CDT 2006
Hi,
>Is it possible to programmatically replace all manual page breaks in a
>document with Next Page Section Breaks?
programmatically there are no manual page breaks.
There are breaks of certain types:
'wdSectionContinuous ' 0
'wdSectionNewColumn ' 1
'wdSectionNewPage ' 2
'wdSectionEvenPage ' 3
'wdSectionOddPage '4
Maybe you can adapt the following,
otherwise ask again.
Sub test012()
Dim rDcm As Range ' the documents range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = Chr(12)
While .Execute
rDcm.Select ' for testing using [F8]
MsgBox KindofBreak12(rDcm)
' rDcm.Collapse Direction:=wdCollapseEnd
' might be necessary together with replace
Wend
End With
End Sub
Public Function KindofBreak12(ByVal rTmp As Range) As String
Dim lSct1 As Long ' counter for sections
Dim lSct2 As Long ' counter for sections
Dim lKoSc As Long ' kind of section.pagesetup.sectionstart
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 = "ordinary page break"
Exit Function
End If
' next character is in the next section
lKoSc = ActiveDocument.Sections(lSct2).PageSetup.SectionStart
Select Case lKoSc
Case 0: KindofBreak12 = "wdSectionContinuous"
Case 2: KindofBreak12 = "wdSectionNewPage"
Case 3: KindofBreak12 = "wdSectionEvenPage"
Case 4: KindofBreak12 = "wdSectionOddPage"
End Select
End Function
see in addition:
http://tinyurl.com/hkrxd
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"