PDA

View Full Version : pagebreak for Word.Application object - HOW



Mr Doubtfire
04-27-2005, 11:06 AM
Could anyone tell me how to apply/add a page break to end a page?
Thanks!

MOS MASTER
04-27-2005, 11:30 AM
Could anyone tell me how to apply/add a page break to end a page?
Thanks!
Selection.InsertBreak Type:=wdPageBreak


:whistle:

fumei
05-02-2005, 07:39 AM
Well Joost, that is technically correct, but does not fully answer.

Your code inserts a page break as if you do a Ctrl-Enter. Essentially a Chr(12).

Selection.InsertBreak Type:=wdSectionBreakNextPage

also makes a Chr(12), but makes it a different section. Which sometimes is what you want. It adds a page break as a section page break. A possibly important distinction.

MOS MASTER
05-02-2005, 10:54 AM
Hi Gerry,

With you arround there is no such thing as a fully answered question! :rofl:

I could have just answered:
Selection.InsertBreak

Simply because wdPageBreak is the default.

The OP didn't specify what kind off break he wanted so just let him specify it for us? :whistle:

fumei
05-02-2005, 11:23 AM
Hmmmm. I am not sure how to take that. Shrug, oh well, I will think of it as very much like Word itself....never fully answered. Or answerable. Word has its own odd twists, does it not?

I did not mean to sound critical - and, ahem, cough.....I can see that it could have looked that way. Just pointing out that there are page breaks, and there are....other page breaks.

I was just thinking about them re: the post on IF statements that requires testing for the specific reason for a page break. Also remember that if text rolls on and creates a new page, there is, in fact, NO page break between them. Even though it is a different page. Thus there are three conditions that make a page different from the proceeding page.

1. An explicit SectionPageBreak.
2. An explicit PageBreak
3. A derived, or calculated page break which uses the pagination operation of Word to set the Range.Start integer of every character within the parameters of the predefined bookmark "\page".

So, technically, you can make it LOOK LIKE a page break by inserting emough blank text characters (ie spaces or empty paragraph marks) from the end of the current text. This would push the calculated (derived) range into a new page. This would look like a page break, but in fact would, technically, not be - it would be condition #3.

You could calculate the number of characters needed to do this. In fact, this can be a viable method if you make the "empty" text a bookmark. That allows manipulation if required. It also eliminates unneeded "hard" page breaks that can be a problem later on.

Ah...Word...it just goes on and on and on.

MOS MASTER
05-02-2005, 11:26 AM
Hahaha...Gerry please take it as a joke it was intended as one!
:rofl:

You just like talking one and one about Word...(Love that to myself so keep 'm comming) :friends:

MOS MASTER
05-03-2005, 01:28 PM
Could anyone tell me how to apply/add a page break to end a page?
Thanks!
Hi,

Just wondering...is it solved for you? :whistle: