Connections Collection --> Help really appreciated

M

Matt B

Hey All,

Im having a problem finding ALL shapes connected (glued) to a particular
connection Point.
Is there a way to test/find all shapes which are connected to a particular
point?

In the example I am using I have a SERVER shape smack bang in the middle of
the page.
The SERVER shape represents a Server & has one (1) Inward Connection Point.
Around the server are 10 workstations, all connected to the single point on
the server, this looks like a star topology.
The workstation shapes were added in no particular order.

I would like to find all the connected workstations & the server, which are
connected to a particular point - on the server.
The problem is as each shape is connected it connects to the previously
connected shape's connection point, not the origional SERVER connection
point. So when I get the shapes collection for the server, all I see is the
first connected workstation shape.
I have been working with the Connections Collection (Connects, FromConnects,
FromSheet etc.) to find the connections of shapes. Below is some code I have
been experimenting with. Hopefully this helps clarify.

Many Thanks
Matt




Dim shpActiveShape As Visio.Shape
Dim intLoopCounter As Integer
Dim intItemNumber As Integer

Set shpActiveShape = Visio.ActiveWindow.Selection.Item(1)
intItemNumber = 1
Debug.Print " "
Debug.Print "<------------------------>"
Debug.Print " " & shpActiveShape.Name
Debug.Print "<------------------------>"

' Get the number of shapes connected to the selected shape
intLoopCounter = shpActiveShape.FromConnects.Count
Debug.Print intLoopCounter & " Shapes in FromConnects.Item.Fromsheet."

Do While intItemNumber < intLoopCounter + 1
Debug.Print
shpActiveShape.FromConnects.Item(intItemNumber).FromSheet.Name
intItemNumber = intItemNumber + 1
Loop

' ----------------Test the ToSheet--------------------
intItemNumber = 1

intLoopCounter = shpActiveShape.Connects.Count
Debug.Print intLoopCounter & " Shapes in Connects.Item.ToSheet"

Do While intItemNumber < intLoopCounter + 1
Debug.Print shpActiveShape.Connects.Item(intItemNumber).ToSheet.Name
intItemNumber = intItemNumber + 1
Loop

' ----------------Test the ToSheet--------------------
intItemNumber = 1

intLoopCounter = shpActiveShape.Connects.Count
Debug.Print intLoopCounter & " Shapes in Connects.Item.FromSheet"

Do While intItemNumber < intLoopCounter + 1

Debug.Print shpActiveShape.Connects.Item(intItemNumber).FromSheet.Name
intItemNumber = intItemNumber + 1
Loop
 

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