Hi LEU,
I'm not sure what you mean when you said to try "KinfofBreak12". I looked at
the site but I didn't understand it. Could you give me more detail on how to
write this?
You search for chr(12).
If found, you feed the found range of this chr(12)
into the function kindofbreak12.
The function returns a long number,
which represents the kind of pagebreak,
as the pagebreak character itself
can't tell you what kind of pagebreak it stands for.
What kind of pagebreak it is, is defined
in the section's pagesetup sectionstart.
In addition, if the found character 12
and the next character are in the same section,
then we got an ordinary pagebreak.
You may start with something like the code below.
Couldn't get it to work with range,
no matter how hard I tried,
maybe somebody else is smarter than me today.
This somebody should think of any number
of continuous pagebreaks and other pagebreaks
not separated by any other character.
Here and now it is over my head.
HTH nevertheless:
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
Sub Test90012A()
ActiveDocument.Range(0, 0).Select
With Selection.Find
.Text = "^0012"
While .Execute
If KindofBreak12(Selection.Range) = 0 Then
Selection.Text = Chr(13)
Selection.End = ActiveDocument.Range.End
End If
Wend
End With
End Sub
Don't forget to reset search options beforehand, like
Public Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
End Sub
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"