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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing a page in Word

Status
Not open for further replies.

mike718

Programmer
Jul 7, 2004
58
US
I have to remove the last page of a document. I have tried to use commands such as selection.delete but that ony seems to remove the page contents and not the page. Can anyone give some input as to what may work??

Thanks
 
The solution depends on what is causing the last page to remain (eg extraneous para mark, page break or section break).

If it's just a matter of an extraneous para mark or page break, you'll have to delete that too. Likewise if it's a section break, but in this case you'll need to be careful about the implications for page attributes (eg dimensions, headers & footers), since deleting a section break causes the previous section to inherent the attaributes of the deleted section.

Cheers
 
It probably would have been a little better if I added some more info on the document. I am using the ActiveDocument.Bookmarks("\page").Select command to select the current page and pasting into a new document. The problem is that this command is copying onto the top portion of the second page not including the second page. This where my problem starts.
 
The problem is that this command is copying onto the top portion of the second page not including the second page.

Huh? What second page? The ("\page") bookmark, if selected, includes the last paragraph mark. These are numbers.

If you do NOT want to include the last paragraph mark, but still select the contents of the ("\page") bookmark, you need to make the selection a range like this:

Code:
Dim r As Range
Set r = ActiveDocument.Range(Start:=ActiveDocument _
.Bookmarks("\page").Start, _
End:=(ActiveDocument.Bookmarks("\page").End - 1))
r.Select
r.Copy

So you have a selection of that page. You are pasting into a new document (at least you state this). If it is a new document, how can there be a second page? The only way is if the margins that held the selected page are different from the new document, and the selection spills over into a new page.

Could you clarify a bit more? What does "top portion of the second page not including the second page" mean?

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top