Oops - sorry, yes the same exact code - wasn't paying attention to which
object's connect object you were referencing. Right, so I only get a count
of 1 and only one shape name shows up once. (and it does appear that the
connects collection passed back is only the added ones, so disregard that
comment)
Maybe another debug idea is to just write a very simple separate module
procedure for checking the connect objects of a selected shape, so you can
just call it as a macro after selecting the shape that's causing you problems
to verify there really are 2 connect objects for that shape. Below is a
procedure I use to check connections, which I copied from someone else
(Microsoft probably) - it shows both from and to connections, it only checks
it for the first selected shape, and may not be the fastest/cleanest method
but for debug purposes its fine i think:
Public Sub ListConnections()
Dim shpsObj As Visio.Shapes
Dim shpObj As Visio.Shape
Dim fromObj As Visio.Shape
Dim fromData As Integer
Dim fromStr As String
Dim toObj As Visio.Shape
Dim toData As Integer
Dim toStr As String
Dim consObj As Visio.Connects
Dim frmconsObj As Visio.Connects
Dim conObj As Visio.Connect
Dim frmconObj As Visio.Connect
Dim curShapeIX As Integer
Dim I As Integer
Dim selectObj As Visio.Selection
Set selectObj = ActiveWindow.Selection
Set shpObj = selectObj.Item(1)
Set shpsObj = shpObj.Shapes
For curShapeIX = 0 To shpsObj.Count
If curShapeIX > 0 Then
Set shpObj = shpsObj.Item(curShapeIX)
End If
Set consObj = shpObj.Connects
'get info for connects to shapes
For I = 1 To consObj.Count
Set conObj = consObj(I)
Set fromObj = conObj.FromSheet
fromData = conObj.FromPart
Set toObj = conObj.ToSheet
toData = conObj.ToPart
'FromPart property values
If fromData = visConnectError Then
fromStr = "error"
ElseIf fromData = visNone Then
fromStr = "none"
ElseIf fromData = visLeftEdge Then
fromStr = "left"
ElseIf fromData = visCenterEdge Then
fromStr = "center"
ElseIf fromData = visRightEdge Then
fromStr = "right"
ElseIf fromData = visBottomEdge Then
fromStr = "bottom"
ElseIf fromData = visMiddleEdge Then
fromStr = "middle"
ElseIf fromData = visTopEdge Then
fromStr = "top"
ElseIf fromData = visBeginX Then
fromStr = "beginX"
ElseIf fromData = visBeginY Then
fromStr = "beginY"
ElseIf fromData = visBegin Then
fromStr = "begin"
ElseIf fromData = visEndX Then
fromStr = "endX"
ElseIf fromData = visEndY Then
fromStr = "endY"
ElseIf fromData = visEnd Then
fromStr = "end"
ElseIf fromData >= visControlPoint Then
fromStr = "controlPt_" & _
Str(fromData - visControlPoint + 1)
Else
fromStr = fromData
End If
If toData = visConnectError Then
toStr = "error"
ElseIf toData = visNone Then
toStr = "none"
ElseIf toData = visGuideX Then
toStr = "guideX"
ElseIf toData = visGuideY Then
toStr = "guideY"
ElseIf toData >= visConnectionPoint Then
toStr = "connectPt_" & _
CStr(toData - visConnectionPoint + 1)
Else
toStr = toData
End If
MsgBox (shpObj.Name & ": Connected to another shape from " & _
fromObj.Name & " " & fromStr & " to " & toObj.Name & " " &
toStr & ".")
Next I
'get info for connects from shapes
Set frmconsObj = shpObj.FromConnects
For I = 1 To frmconsObj.Count
Set frmconObj = frmconsObj(I)
Set fromObj = frmconObj.FromSheet
fromData = frmconObj.FromPart
Set toObj = frmconObj.ToSheet
toData = frmconObj.ToPart
'FromPart property values
If fromData = visConnectError Then
fromStr = "error"
ElseIf fromData = visNone Then
fromStr = "none"
ElseIf fromData = visLeftEdge Then
fromStr = "left"
ElseIf fromData = visCenterEdge Then
fromStr = "center"
ElseIf fromData = visRightEdge Then
fromStr = "right"
ElseIf fromData = visBottomEdge Then
fromStr = "bottom"
ElseIf fromData = visMiddleEdge Then
fromStr = "middle"
ElseIf fromData = visTopEdge Then
fromStr = "top"
ElseIf fromData = visBeginX Then
fromStr = "beginX"
ElseIf fromData = visBeginY Then
fromStr = "beginY"
ElseIf fromData = visBegin Then
fromStr = "begin"
ElseIf fromData = visEndX Then
fromStr = "endX"
ElseIf fromData = visEndY Then
fromStr = "endY"
ElseIf fromData = visEnd Then
fromStr = "end"
ElseIf fromData >= visControlPoint Then
fromStr = "controlPt_" & _
Str(fromData - visControlPoint + 1)
Else
fromStr = fromData
End If
If toData = visConnectError Then
toStr = "error"
ElseIf toData = visNone Then
toStr = "none"
ElseIf toData = visGuideX Then
toStr = "guideX"
ElseIf toData = visGuideY Then
toStr = "guideY"
ElseIf toData >= visConnectionPoint Then
toStr = "connectPt_" & _
CStr(toData - visConnectionPoint + 1)
Else
toStr = toData
End If
MsgBox (shpObj.Name & ": Connected from another shape from " & _
fromObj.Name & " " & fromStr & " to " & toObj.Name & " " &
toStr & ".")
Next I
Next curShapeIX
End Sub
-hadriel