getting a style to start the next page

A

adrian

Hi all,

I am programatically filling a doc with data.

All the data appears under a heading (the heading is the
job number which has been formatted as style Heading1)

I want to avoid a situation where the data relating to a
single Job number straddles two docs. In other works:-

If the whole job details cannot fit on the same page, then
insert a page break and start that job at the beginning of
the new page.

Am I on the right lines by assuming that the best way to
go would be to programmatically check that the first line
in the doc is formatted Heading1. If not then insert a
page break just before the previous instance of Heading1.

If this is the best way, can anyone help me with some code
or at least a point in the right direction.

Thank you

Adrian
 
J

Jezebel

You seem to be using 'doc' to mean 'page' ... if you really do mean
document, then I don't understand you question, but assuming you mean page
.....

A simple method, if your data permits it, is to set all the styles you use,
except that for the last paragraph of each job, to 'keep with next'.

Alternatively, iterate the paragaphs of the document. Each time you meet a
'heading 1' make a note of the paragraph index and page number (use the
Information function). For all other paragraphs, if you meet a page number
greater than the preceding heading 1, set that heading 1 paragraph to 'page
break before'.
 
A

Adrian

Hi Jezabel

Yes you are quite right I did mean "Page"

Many thanks for your assistance. I will work on your
suggestions.

Reagrds

Adrian
 
P

Peter Hewett

Hi Adrian

If your using the style Heading1 for the first line of each new job (page).
Then all you need to do is set the Heading1 styles paragraph property "Page
Break Before" to True. Wod will automatically page break before every
occurrence of Heading1 other than the first.

You don't need to use code for this you can just make this change to your
templates Heading1 style definition.

HTH + Cheers - Peter
 
T

Tim Ferguson

Yes, but then every job would be on a separate page, which is not the
requirement.

"Keep with next" will do what you want, but make sure that the next
paragraph is not empty: i.e. use Paragraph Spacing to space the paragraphs,
not empty paras. IYSWIM


B Wishes


Tim F
 

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