API Documentation > CorelDRAW > 2025-v26 > Node > IVGNode
Node.ConnectWith method
Connects this node with another one (if possible)
Syntax:
Sub ConnectWith(ByVal Target As Node)
Parameters:
Name Type Description
Target
Remarks:
The ConnectWith method connects two ending nodes by drawing a straight line between them. The JoinWith method connects two ending nodes by merging them into one.
Examples:
The following VBA example connects the ending node of each open subpath with the starting node of the next open subpath.
Sub Test()
Dim s As Shape
Dim spath As SubPath
Dim n1 As Node, n2 As Node
Dim Joined As Boolean, Repeat As Boolean
Set s = ActiveShape
If s.Type <> cdrCurveShape Then s.ConvertToCurves
  Repeat = True
  While Repeat

 Set n1 = Nothing

 Set n2 = Nothing

 Joined = False

 For Each spath In s.Curve.Subpaths


If Not spath.Closed Then


  If n2 Is Nothing Then



 ' The first open SubPath found



 Set n1 = spath.StartNode



 Set n2 = spath.EndNode


  Else



 ' n2 is the last node of previous open SubPath



 ' Join it with the first node of the current subpath



 n2.ConnectWith spath.StartNode



 ' Joining subpaths reduces the number of subpath in the curve



 ' So we need to restart



 Joined = True



 Exit For


  End If


End If

 Next spath

 If Not Joined Then


If Not n1 Is Nothing Then


  ' There's only one open subpath left. Close it


  n1.ConnectWith n2


End If


Repeat = False

 End If
  Wend

End Sub