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

Not sure if I can ask a question about MS Word?

Status
Not open for further replies.

feipezi

IS-IT--Management
Aug 10, 2006
316
US
Hi,

Please ignore what I ask if I'm not supposed to raise a MS Word question.

It's a quick question. How can I remove or delete a page from a Word document? I googled around but unable to find a decent solution. I don't understand why it's so hard to delete a page in Word, instead of easy removal of a tab in Excel, a sort of operation we do almost everyday.

I tried this but it worked unless it's the last page.

Sub RemovePage()
Selection.GoTo wdGoToPage, wdGoToAbsolute, 7
ActiveDocument.Bookmarks("\page").Range.Delete
End Sub

Thanks in advance

 
A better place to ask VBA question would be forum707
But you can try this place to find your answer (I hope)

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Because the concept of a 'page' is a somewhat fluid concept. For example if I change point size from 10 to 12 pagination will change.
 
...or if you selected a different printer,the automatic pagination would likely change.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
A more efficient macro for deleting the last page would be:
Code:
Sub RemovelastPage()
Application.ScreenUpdating = False
With ActiveDocument
  .GoTo(What:=wdGoToPage, Name:=.ComputeStatistics(wdStatisticPages)).GoTo(What:=wdGoToBookmark, Name:="\page").Delete
End With
Application.ScreenUpdating = True
End Sub
As for why you can't delete the last page, that could be due to there being a table that terminates the penultimate page. Since, in Word, there must always be at least one paragraph following a table, you may end up with an empty page in such cases. The solution in such cases is to set that last paragraph's:
1. before/after settings to 0;
2. point size to 1; and/or
3 font format to 'hidden text'.

Cheers
Paul Edstein
[MS MVP - Word]
 
Word data limit is expandable where as in excel, the cells in each sheet are fixed, apart from this, you can insert a sheet based on your preference without impacting other sheets but in word, page number would only change based on your data input (including blank spaces)
 
Thanks folks!

But macropod's code only removed the contents of the table, not the whole table. Not sure what I did was wrong.

Let me tell you guys what I did.

The Sub RemovePage() works on most of the pages, except for the last one. I placed the cursor at the end of the last page that I wanted to remove; then kept pressing Enter to push the cursor down to a new page after the last page; then go to Page Layout->Break->Continuous; then run RemovePage() again. Now the last page together with the new page will be gone. Btw, I had to put down the right page number in the Sub.

Not the best way of doing it but at least it works for me. Can I save the report in Excel, after removing the irrelevant pages and save back to Word? Guess it won't work!

Thanks again for all your input.
 
But macropod's code only removed the contents of the table, not the whole table. Not sure what I did was wrong.
Most likely you changed the code from what I posted. As posted, the code deletes all content on the last page, including any part of a table that is on that page. And you don't have to input the page #.

Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top