Get the shapes involved in the last Deleted Connection

M

Matt B

I have a Visio Shape connected to another, using the Dynamic Connector.
If I was to remove the connection between one of the shapes and the Dynamic
Connector is the a way to get 'both' the shapes involved in the deleted
connection.
Basically I wish to get both the shapes involved in the connection before
they the connection is removed.
Something like a BeforeConnectionDeleted event. Or maybe I can get the info
from the connects collection?

I am currently using the WithEvents - ConnectionsDeleted method to trigger
my VBA script. By then its to late to test the connections as the connection
has been removed.

Many Thanks
M@
 
A

Andy

Check out using the "QueryCancelSelectionDelete" event. This fires
before the delete occurs and allows you to cancel the event if you
chose.
-andy
 
M

Matt B

Thanks Andy,

This will be most useful, however what I need is to get the Visio Shapes
from which a connection is being removed.
See both shapes are stored in an Access Database & the database stores the
fact they are connected.
I need to remove the connection entry, between the two shapes, in the Access
Database.

For example:
A user connects one end of a Dynamic Connector to a shape of a PC.
That connection is recorded in the database.
Now the user removes that connection (not deletes the shape).
The connection information in the database needs to be deleted.
For this I need the name of the two shapes, from which the connection was
broken (Dynamic Connector & PC Shape).
Along with the connection information other data is stored in the database,
which must be removed if a connection is broken / unconnected.

Maybe there is another method to track the connection / un-connection of
shapes?

Many Thanks
M@
 
S

Sergei

It seems to be a bug - there does not seem to be a way.
I had the same problem and had to implement it manually - e.g. have lists of
all shapes and all connections pointing to shapes so when a connection is
deleted I can find my own connection object in the list and see which shapes
it was connected to.
You can use your database primary key to find a connection in the list, for
example.
Ta
Sergei.
 
M

Mike Z

Hi Matt,

What I did was to find the two Connects of the connector that you've
guessed, and then to get the two shapes at the connects. The follows are
pieces of sample code, though it's in C++, used in retrieving the connects,
from which the shapes are found.

Good luck,

Mike

{
.......
CVisioConnect visConnect1, visConnect2;

if ( !GetConnects( visShape, visConnect1, visConnect2 ) )

return false;

visConnect1.ToSheet( visShapeFrom );

visConnect2.ToSheet( visShapeTo );

.......

}

bool CMyClass::GetConnects( CVisioShape& visConn, CVisioConnect& visConn1,
CVisioConnect& visConn2 )

{

CVisioConnects visConnects;

visConn.Connects(visConnects);

visConnects.Item(1, visConn1 );

visConnects.Item(2, visConn2 );

return ( (bool)(visConn1.IsSet( ) && visConn2.IsSet( )) );

}
 
M

Matt B

Thanks Sergi & Mike Z :)

I have been workin with the Connects Collection in my initial development
and had hoped to find a better solution.
When I say a better solution, something that involves not executing code
(tests) every time a connection is made or removed. Not so it would appear.

A simple BeforeConnectionRemoved event, which gives you a chance to test the
shape(s) before the removal of the connection would go a long way to solving
this.

Thanks Again,
Oh, and any further suggestions are MOST welcome :)
 

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