How to locate a PageBreak

J

Jamie Carper

Hi Folks,

I have some documents that I do not have any control over. Since I
cannot rely on any standard or proper formatting I am left with having
to approximate sections of these documents. One way I have gone about
this is to locate a unique phrase and then step thru the paragraphs
looking for unique patterens.

In doing so I need to be able to identify a PageBreak (hard or manual)
in a given paragraph. I have tried searching on the Control Character
12 but failed. However if I search on characters less then ASCII value
32 I get some success but I need to be able to find PageBreaks
specifically.

This does works, but only if the PageBreak is alone:

Do While (MyParagraph .Range.Text > Chr(31))
Set MyParagraph = MyParagraph .Next
Loop

Any clue?

Jamie
 
M

Matthew Williams

Hi Jamie

I'm probably misunderstanding what you're doing, but why not just search
using Word's special character code for a page break--^m?
 
D

Dave Lett

Hi Jamie,

You can find a hard page break with something like the following (which
selects the manual page break):

With Selection.Find
.ClearFormatting
.text = "^m"
If .Execute Then
MsgBox "Hard Page break in selection."
End If
End With

OR you can use the following (which does _not_ select the manual page
break):

If InStr(1, Selection.text, Chr(12)) <> 0 Then
MsgBox "Hard Page break in selection."
End If

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top