How do I delete all the pages in a visio.Document ?

A

ahmadka

Hi guys....well I know that you can add pages to visio control's document
using the following command:

visioControl.Document.Pages.Add();

But what do I do if I want to delete pages from a visio control's document
?? Specifically, I wish to delete all the pages from a visio control's
document. How do I do this ?
 
J

JuneTheSecond

Delete method to the page object deletes the page.
ThisDocument.Pages(2).Delete 0 deletes the second page.
But you cannot delete the page, if there is only one page.
So, you cannot delete all pages.
 
A

ahmadka

So that means that if there are 5 pags, I can delete upto 4, using these
statements:

visioControl.Document.Pages[1].Delete(0);
visioControl.Document.Pages[2].Delete(0);
visioControl.Document.Pages[3].Delete(0);
visioControl.Document.Pages[4].Delete(0);

and then delete all the shapes off the 5th page ?
 
P

Paul Herber

So that means that if there are 5 pags, I can delete upto 4, using these
statements:

visioControl.Document.Pages[1].Delete(0);
visioControl.Document.Pages[2].Delete(0);
visioControl.Document.Pages[3].Delete(0);
visioControl.Document.Pages[4].Delete(0);

Remember that when you delete page 1 that there are then only pages 2
to 5 left but reindexed as 1 to 4, then if you delete page 2 that the
pages left are the new page 1 and page 3 ( now page 2).
So, deleting from Document.Pages.Count downto 2 will leave you with 1
page.
 
A

ahmadka

OK then, here comes the next question: how do I delete all the shapes off the
last remaining page ?
 

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