Visio Diagrams with Python: Connectors

Connect two existing Shapes

The API is somehow weird, since it creates an (Shape-)Object, but it doesn’t return it.

  • you’ll have to fetch the last object in the shapes-List
#https://docs.microsoft.com/en-us/office/vba/api/visio.shape.autoconnect
rect1.AutoConnect(rect2,0)
#
#https://docs.microsoft.com/en-us/office/vba/api/visio.shapes.itemu
connector1=shapes.ItemU(len(shapes))
#
connector1.Text = "Connector1"
# 
#https://docs.microsoft.com/de-de/office/client-developer/visio/linecolor-cell-line-format-section
# * color "3" is "light green"
connector1.Cells("LineColor").FormulaForce = 3
#
#https://docs.microsoft.com/de-de/office/client-developer/visio/conlinerouteext-cell-shape-layout-section
# * ConLineRouteExt "2" is "Curved"
connector1.Cells("ConLineRouteExt").FormulaForce = 2

Result

>>> len(shapes)
6

Schreibe einen Kommentar