Shape.AutoConnect method (Visio)
Automatically draws a connection in the specified direction between the shape and another shape on the drawing page.
Syntax
expression. AutoConnect
( _ToShape_
, _PlacementDir_
, _Connector_
)
expression An expression that returns a Shape object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
ToShape | Required | [IVSHAPE] | The shape to draw the connection to. |
PlacementDir | Required | VisAutoConnectDir | The direction in which to draw the connection. See Remarks for possible values. |
Connector | Optional | [UNKNOWN] | The connector to use. |
Return value
Nothing
Remarks
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.
Constant | Value | Description |
---|---|---|
visAutoConnectDirDown | 2 | Connect down. |
visAutoConnectDirLeft | 3 | Connect to the left. |
visAutoConnectDirNone | 0 | Connect without relocating the shapes. |
visAutoConnectDirRight | 4 | Connect to the right |
visAutoConnectDirUp | 1 | Connect 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)
Example
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기