How to delete more than 2 pages at a time in Publisher

J

JT

I've got a 600 page Publisher 2003 document and want to delete 200 pages. Is
there an easier way of doing this instead of doing EDIT > DELETE PAGE > BOTH
PAGES 100 times!?


----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...ae-a9712c55fadc&dg=microsoft.public.publisher
 
E

Ed Bennett

JT said:
I've got a 600 page Publisher 2003 document and want to delete 200
pages. Is there an easier way of doing this instead of doing EDIT >
DELETE PAGE > BOTH PAGES 100 times!?

Use a macro.

Go to Tools > Macro > Visual Basic Editor
Double-click Project > Microsoft Publisher Objects > ThisDocument.

Copy and paste the following into the code window:

'BEGIN COPY
Sub DeletePageXToY()
Dim X As String, Y As String
Dim Xi As Integer, Yi As Integer

X = InputBox("Enter the number of the first page you would like to
delete")
If X = "" Then Exit Sub

Y = InputBox("Enter the number of the last page you would like to
delete")
If Y = "" Then Exit Sub

Xi = Val(X)
Yi = Val(Y)
If Not (Xi = Val(X) And Yi = Val(Y)) Then Beep: Exit Sub

If Y < X Then Beep: Exit Sub
If X > ThisDocument.Pages.Count Then Beep: Exit Sub

ThisDocument.BeginCustomUndoAction "Delete Pages " & X & " to " & Y &
"."

Dim i As Integer
For i = X To Y
ThisDocument.Pages(X).Delete
Next

ThisDocument.EndCustomUndoAction
End Sub
'END COPY

Click inside the sub (say, click on ThisDocument.BeginCustomUndoAction), and
click the big green Play button on the toolbar. Follow the on-screen
instructions.
 
E

Ed Bennett

JT said:
I've got a 600 page Publisher 2003 document and want to delete 200
pages. Is there an easier way of doing this instead of doing EDIT >
DELETE PAGE > BOTH PAGES 100 times!?

N.B. The code posted only works as expected if the page numbers start at 1
and run without breaking. Otherwise, pages other than the ones you expect
to disappear will be deleted.
 

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