End of page or not

J

Junaid

Hello,
I'm pasting several subdocuments together to create one document using
macros but sometimes that creates blank pages among them since I'm inserting
page break before pasting the next document.

I found out that this happens with documents that have already filled their
last page. Not all of my documents fill their last page so I have to insert
page breaks on those.

Is there a way to conditionally insert a page break based on if the end of
the document lies in the middle of a page or not. I would really appreciate
any input.

Thanks
Junaid
 
H

Helmut Weber

Hi Junaid,
for a simple, line based approach, I think, this would do:
Dim r As Range
Dim l as integer ' line number
Set r = ActiveDocument.Range
l = r.Information(wdFirstCharacterLineNumber)
---
A simple approach, because it is assumed, that your
pages have a reliable average number of lines.
Let's say 60. So if you would use a condition like
if l is between 25 and 35, what is approximately
in the middle, it might help you.
Otherwise, it is possible, to place the cursor at
the end of the document and get the position in
points relative to the page. But that is certainly
overdoing it right here.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT4.0
 
H

Helmut Weber

....
of course not
r.Information(wdFirstCharacterLineNumber)
but
r.Collapse direction:=wdCollapseEnd
MsgBox r.Information(wdFirstCharacterLineNumber)
....
Sorry
 

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