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

Shape.AutoConnect Method (Visio)

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

Automatically draws a connection in the specified direction between the shape and another shape on the drawing page.


expression . AutoConnect( ToShape , PlacementDir , Connector )

expression An expression that returns a Shape object.


NameRequired/OptionalData TypeDescription
ToShapeRequired[IVSHAPE]The shape to draw the connection to.
PlacementDirRequiredVisAutoConnectDirThe direction in which to draw the connection. See Remarks for possible values.
ConnectorOptional[UNKNOWN]The connector to use.

Return Value



The AutoConnect method lets you automatically draw connections between shapes on the drawing page while specifying the direction of the connection and, optionally, the connector.

For the ToShape parameter, pass the Shape object to which you want to draw the connection.

For the PlacementDir parameter, pass a value from the VisAutoConnectDir enumeration to specify the connection direction?that is, where to locate the connected shape with respect to the primary shape. Possible values for PlacementDir are as follows.

visAutoConnectDirDown2Connect down.
visAutoConnectDirLeft3Connect to the left.
visAutoConnectDirNone0Connect without relocating the shapes.
visAutoConnectDirRight4Connect to the right
visAutoConnectDirUp1Connect up.

If your Visual Studio solution includes the Microsoft.Office.Interop.Visio reference, this method maps to the following types:

  • Microsoft.Office.Interop.Visio.IVShape.AutoConnect(Microsoft.Office.Interop.Visio.Shape, Microsoft.Office.Interop.Visio.VisAutoConnectDir, object)


The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the AutoConnect method to draw a connection between two flowchart shapes, a decision shape and a process shape, by using a third shape, a dynamic connector, all of which were added to an empty drawing page from the Basic Flowchart Shapes (US Units) stencil.

Because the example calls the method on the decision shape, Visio draws the connector from the decision shape to the process shape. Because we pass the method the enumerated value visAutoConnectDirRight for the PlacementDir parameter, Visio places the process shape automatically to the right of the decision shape on the drawing page, regardless of its previous location.

Public Sub AutoConnect_Example() 

    Dim vsoShape1 As Visio.Shape 
    Dim vsoShape2 As Visio.Shape 
    Dim vsoConnectorShape As Visio.Shape 

    Set vsoShape1 = Visio.ActivePage.Shapes("Decision") 
    Set vsoShape2 = Visio.ActivePage.Shapes("Process") 
    Set vsoConnectorShape = Visio.ActivePage.Shapes("Dynamic connector") 

    vsoShape1.AutoConnect vsoShape2, visAutoConnectDirRight, vsoConnectorShape 

End Sub
© 2017 Microsoft