mcwhirt3@msu.edu <mcwhirt3@msu.edu> was very recently heard to utter:
> I can't get this to work though. Is there any better way to delete all
> of the pages in a document?
You are not allowed to delete all of the pages in the document.
In addition, the code you posted should delete the LAST page in the
publication.
You want something like
Dim i As Integer
For i = NoOfPages to 2
ActiveDocument.Pages(i).Delete
Next
This will leave page 1 remaining.

Signature
Ed Bennett - MVP Microsoft Publisher
mcwhirt3@msu.edu - 23 Nov 2005 01:22 GMT
Hi Ed,
Thanks for your help. I can;t get it o work..the code is
Private Sub CommandButton9_Click()
noofpages = PageCount
Dim i As Integer
For i = noofpages To 2
ActiveDocument.Pages(i).Delete
Next
End Sub
Any idea why?
mcwhirt3@msu.edu - 23 Nov 2005 02:02 GMT
P.S.
I get a supscript out of range error when running that code. Thanks
again Ed!
Ed Bennett - 23 Nov 2005 08:24 GMT
mcwhirt3@msu.edu <mcwhirt3@msu.edu> was very recently heard to utter:
> noofpages = PageCount
Try replacing this with
noofpages = ActiveDocument.Pages.Count

Signature
Ed Bennett - MVP Microsoft Publisher