Working with the Connects Collection

G

Gerald K

Hi - I am trying to view the connects collection for an object (arc) so I can
then check if the two objects connected are of the same type or not.
I have written the following code, but it doesn't seem to work:
arcConns.Count (the number of connections) is always zero!

I am calling this procedure from the EventXFMod field in the shapesheet.

Any ideas what's wrong???
-------------------------------

Sub ValidateLink(shpObj As Visio.Shape)

Dim mastObj As Master
Dim fromObj As Shape
Dim arcConns As Connects
Dim arcConn As Connect
Dim intCounter As Integer

Set mastObj = shpObj.Master
' Get Master property of shape
Set arcConns = mastObj.Connects
' Get the connects collection of the source shape

For intCounter = 1 To arcConns.Count
Set arcConn = arcConns(intCounter)
Set fromObj = arcConn.FromSheet

MsgBox ("connector: " + fromObj.Name)
Next intCounter

End Sub
 
J

junethesecond

Your code seems to work well, if you are calling this macro from action
cell with pop up menu.
Plese note that the master of a set of connected shapes becomes a group
when you drop it, and the argument, shpObj in you macro is the grouped
shape, not the connector in the group.
 
G

Gerald K

Thanks for your response. Still leaves me baffled though - I'm only dropping
a single object (a customised arrow) whose EventXFMod action calls the
routine. I've tried calling the routine from other objects and still doesn't
'see' the Connects Collection.
 
J

junethesecond

I see. Your code works very well called from EventXFMod cell.
Code skips the for loop, because the master is a single shape. Would you
please read about Connect object in the Visio Help.
 
G

Gerald K

Yes, have looked at Visio help. It says that I can retrieve and Connect
object from the "Connects collection of a Page or Master object". Doesn't a
single shape, such as the Master, have a Connects collection that represents
the multiple objects it connects to?

Is there a better way to find out what objects are connected to a master
shape?
 
J

junethesecond

I think you are right.
An isolated single shape or master has empty connects collection.
If a master is a set of connected shapes , the connecting shape in the
master may have connect objects and may have a connects collection that is
not empty.
 

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