Automation in C# (Page Break)

A

Amrish

Hi, I am generating the TOC of a document using C# by pointing the Range to
the BookMark which i had placed manually on the start of page2. But if my TOC
fills only half the page, then actual contents start fromt he very same page
below the TOC. Is there any way to check if the TOC and actual contents are
present in the same page and if so can we manually include a Page Break?

Could it be Something like this? If so is there a syntax to get the page
number of the selection?

If( PageNumberOf(TOC) == PageNumberOf(Actual Document Contents))
{
Insert Manual Page Break;
}

Or is there any other way to handle this?

-Amrish
 
S

Shauna Kelly

Hi Amrish

I think you're trying to re-invent the wheel here.

Am I right in understanding that your document consists of:

- some text on page 1
- a Table of Contents
- some more text that you want to start on a new page.

If that's so, then format the text after the TOC with "Page Break Before".
That is, Format > Paragraph. On the Line and Page Breaks tab, tick the "Page
Break Before" box.

By the way, manual page breaks are almost always a bad idea. And, it's
generally a good idea to leave one empty paragraph between the TOC and any
subsequent text.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

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