Table of contents
TOC
Collapse the table of content
Expand the table of content

Connect.ToPart Property (Visio)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Returns the part of a shape to which a connection is made. Read-only.

Syntax

expression . ToPart

expression A variable that represents a Connect object.

Return Value

Integer

Remarks

The ToPart property identifies the part of a shape to which another shape is glued, such as its begin point or endpoint, one of its edges, or a connection point. The following constants declared by the Visio type library in member VisToParts show possible return values for the ToPart property.

ConstantValue
visConnectToError-1
visToNone0
visGuideX1
visGuideY2
visWholeShape3
visGuideIntersect4
visToAngle7
visConnectionPoint100 + row index of connection point

Example

This Microsoft Visual Basic for Applications (VBA) macro shows how to extract connection information from a Microsoft Visio drawing. The example displays the connection information in the Immediate window.

This example assumes there is an active document that contains at least two connected shapes.


Public Sub ToPart_Example() 

 Dim vsoShapes As Visio.Shapes 
 Dim vsoShape As Visio.Shape 
 Dim vsoConnectTo As Visio.Shape 
 Dim intToData As Integer 
 Dim strTo As String 
 Dim vsoConnects As Visio.Connects 
 Dim vsoConnect As Visio.Connect 
 Dim intCurrentShapeID As Integer 
 Dim intCounter As Integer 

 Set vsoShapes = ActivePage.Shapes 

 'For each shape on the page, get its connections. 
 For intCurrentShapeID = 1 To vsoShapes.Count 

 Set vsoShape = vsoShapes(intCurrentShapeID) 
 Set vsoConnects = vsoShape.Connects 

 'For each connection, get the shape it connects to 
 'and the part of the shape it connects to, 
 'and print that information in the Immediate window. 
 For intCounter = 1 To vsoConnects.Count 

 Set vsoConnect = vsoConnects(intCounter) 
 Set vsoConnectTo = vsoConnect.ToSheet 
 intToData = vsoConnect.ToPart 

 If intToData = visConnectError Then 
 strTo = "error" 
 ElseIf intToData = visNone Then 
 strTo = "none" 
 ElseIf intToData = visGuideX Then 
 strTo = "guideX" 
 ElseIf intToData = visGuideY Then 
 strTo = "guideY" 
 ElseIf intToData = visWholeShape Then 
 strTo = "dynamic glue" 
 ElseIf intToData >= visConnectionPoint Then 
 strTo = "connection point " &; _ 
 CStr(intToData - visConnectionPoint + 1) 
 Else 
 strTo = "???" 
 End If 

 'Print the name and part of the shape the 
 'Connect object connects to. 
 Debug.Print "To "; vsoConnectTo.Name &; " " &; strTo &; "." 

 Next intCounter 

 Next intCurrentShapeID 

End Sub
© 2018 Microsoft