Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Publisher / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Delete all pages in project

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mcwhirt3@msu.edu - 22 Nov 2005 18:49 GMT
Hi,

  I have a quasi-program that has a button to reset it in publisher,
basically it opens the main menu userform. I need the vb that does that
to first delete all the pages in the document. I believe I want to use
the pagecount property and set that to a variable, then use that
variable in this line...

noofpages=pagecount
ActiveDocument.Pages(noofpages).Delete

I can't get this to work though. Is there any better way to delete all
of the pages in a document? It must reference the pagecount property
because the project will have a variable amount of pages. Thanks for
any help.
Ed Bennett - 22 Nov 2005 19:21 GMT
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


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.