deleting a page/C#/VCD

G

genc ymeri

Hi,
I'm trying to delete a page programmatically but is looking for a
System.int16 (short) paramter where I don;t know where to find it. I did
record a macro deleting a page in MS Visio add the paramter there was a
boolean.

I'm really confused.

Any help very much appreciated.


PS:

axVSDrawing.Document.Application.ActiveDocument.Pages.get_ItemU(aShape.Name)
..delete(???)



Method 'Microsoft.Office.Interop.Visio.IVPage.Delete(short)' referenced
without parentheses
 
C

Chris Roth [ Visio MVP ]

The flag you're looking for is just a boolean flag for whether you want to
renumber the renaming pages or not.

1=True, 0=False.



Try one of these for .NET:

visPg.Delete( 0 )

visPg.Delete( CType(False, Short) )


--

Hope this helps,

Chris Roth
Visio MVP
 
G

genc ymeri

Hi Chris,
Initially that's what I assumed too.

I did try exactly the same things, but an exeption occurs giving not much
info about it. I really do not know what to do.

Any idea will be greatly appreciated.
try
{
axVSDrawing.Document.Pages.get_ItemU(aShape.Name).Delete(0);
//or with Delete(1)

//to assure that I get a page with that name I did something
like

// Microsoft.Office.Interop.Visio.Page oldPage;

//oldPage = axVSDrawing.Document.Pages.get_ItemU(aShape.Name);

//MessageBox.Show(oldPage.Name); // and it works fine which means
I refer to the right page.



}
catch (Exception ex)
{
MessageBox.Show(ex.Message); //exception occurs saying " An
exception occured !" !!: ?????? Not much info
}
 
G

genc ymeri

well, well, well,,,,,,,

I was writting that code under QueryCancelSelectionDelete but when I ran in
under a button click it did work fine,,,,,,

I got to get one way around it...............


Thanks.
 
C

Chris Roth [ Visio MVP ]

That was my next guess, I've had trouble deleting pages in QueryCancel
events. What I sometimes do is build collections of "StuffToDelete" in the
QueryCancel events.

Later on, when VisioIsIdle, or VisNoEventsPending fires, I process the
collections and get rid of all the junk. It's a little harder to set up, but
you have this nice clearing house that can actually make the logic easier to
follow.

--

Hope this helps,

Chris Roth
Visio MVP
 

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