Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

word macro - logical page break

Status
Not open for further replies.

ohigbi

Technical User
Aug 6, 2009
1
US
Is it possible to have a macro insert a page break so many lines down from the top, but not break a block of data - to then logically insert the break before the block that would otherwise be divided? I would need to loop this action an unknown number of times, since the reports vary in content and length. Thanks
 
I'm sure there's a way to count "lines" in a Word document... at least I'd imagine so, since you can move the cursor down so many times...

What else you'd want to check for are line breaks and non-breaking spaces, I suppose.

All in all, I would think it could be done. I don't have the time at the moment to play around with some possibilities in code, but if I get a chance in the next few days, I'll take a look myself... hopefully someone else can before then, that is if the suggestions don't spark some ideas for yourself already. [smile]

--

"If to err is human, then I must be some kind of human!" -Me
 
Hi ohigbi,

Depending on the exact nature ofyour requirements, there may be no need for a macro.

For example, if you format all paragraphs with the 'keep lines together' attribute, a paragraph will never span a page break (unless the paragraph is loner than one page). If you format headings with the 'keep with next' paragraph attribute, they will never end up on a page other than the same page as the first paragraph of the text to which they relate. Similarly, headings formatted with the 'page break before' paragraph attribute will always start on a new page.

All of the above is best handled by Style definitions.

If you really do need a macro, please post in the vba forum (

Cheers
[MS MVP - Word]
 
Yeah, if at all possible, I'd just go with macropod's suggestion - much simpler, less time and more than likely less headache. [wink]

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top