Search notes:

Office Object Model: Visio - Shape

autoConnect

The autoConnect method allows to connct two shapes.
option explicit

sub main()

   dim doc as document
   dim pag as page

   set doc = activeDocument
   set pag = doc.pages(1)

   dim rect1 as shape
   dim rect2 as shape

   set rect1 = pag.drawRectangle(3, 4, 5, 3)
   set rect2 = pag.drawRectangle(3, 2, 5, 1)

   rect1.text = "One"
   rect2.text = "Two"

   dim dynConn as shape

 ' Set dynConn = doc.Pages(1).Shapes("Dynamic connector")

 '
 ' Connect the shapes rect1 and rect2.
 '
 ' The third parameter is required although I fail to see
 ' what it is needed for.
 '
   rect1.autoConnect rect2, visAutoConnectDirNone, dynConn

 '
 ' Unfortunately, AutoConnect does not return the shape (connector)
 ' it created.
 ' Thus, the most recent created shape is assumed to be the
 ' one with the highest count number:
 '
   set dynConn = pag.shapes(pag.shapes.count)

 '
 ' Change end of connect to an arrow:
 '
   dynConn.Cells("EndArrow") = 13

 '
 ' Don't show grid:
 '
   activeWindow.showGrid = false

end sub
Github repository about-MS-Office-object-model, path: /Visio/Shape/autoConnect.bas
The code above produces:

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1759612575, '216.73.216.149', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Visio/Object-Model/Shape/index(94): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78