Deleting Even Pages Within Page-Range

J

Jason Stengren

I'm wondering if this is possible, and if someone could provide (or
point me to) some sample code that would help me build a macro to
accomplish this task...

Let's say I have a 200 page document. The first chapter must remain
static, but all remaining chapters (defined by section breaks) need to
be 'cleaned up' by deleting ALL even-numbered pages.

I would like to bind this to a macro to automate this massive page
deletion process. Ideas?

PS: I've found a code snippet from another thread... how could you
modify it to only delete even pages?

Sub pages_go_away()
Selection.Goto what:=wdGoToPage, which:=wdGoToAbsolute, Count:=4
For counter = 4 to 21
ActiveDocument.Bookmarks("\page").Select
Selectuion.Delete
Next counter
End Sub
 
C

Charles Kenyon

This is a very difficult task, IMO, because Word has very little concept of
pages. They are a construct of sending the document to the printer. Unless
you are very careful in doing this, you will end up with something quite
different from what you expect. Pages simply are not fixed. If I attempted
to write code to do this, I would use it only on copies of documents because
otherwise I would end up losing something valuable.

Perhaps someone could be of more help if you would explain why you need to
do this. What is it you are trying to accomplish by making all even numbered
pages disappear? Also, which version of Word are you using, it could be
important.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide




--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
R

Russ

Jason,
I'm wondering if this is possible, and if someone could provide (or
point me to) some sample code that would help me build a macro to
accomplish this task...

Let's say I have a 200 page document. The first chapter must remain
static, but all remaining chapters (defined by section breaks) need to
be 'cleaned up' by deleting ALL even-numbered pages.

I would like to bind this to a macro to automate this massive page
deletion process. Ideas?

PS: I've found a code snippet from another thread... how could you
modify it to only delete even pages?

Sub pages_go_away()
Selection.Goto what:=wdGoToPage, which:=wdGoToAbsolute, Count:=4
For counter = 4 to 21
You could try:

Dim Mycounter As Long
For Mycounter = 20 to 4 Step -2
Selection.Goto what:=wdGoToPage, which:=wdGoToAbsolute, Count:=Mycounter
ActiveDocument.Bookmarks("\page").Select
Msgbox Selection.Information(wdActiveEndAdjustedPageNumber) 'For testing
'Selection.Delete 'Comment out for testing
Next Mycounter

But I agree with Charles that paging depends on what printer is the active
default printer. If the document is using formatting to force blank even
pages, then change that formatting to not use blank even pages. Also look up
the repaginate method in VBA help for repaginating a document.
 

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