Selecting a connector via code

Started by HankAnzis, April 20, 2018, 06:43:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HankAnzis

Hello,
  In a Visio automation project I am modifying it is requested that the user select a connector from a menu dropdown and then draw the connector on the diagram (the diagram is on a MDI form containing the VISIO diagram). The connector drawing process is started easily enough using the visCmdDRConnectorTool command but I am having trouble finding a way to select the user selected connector. Is thare a way in code to set a preferred connector or make a default connector?
Thanks in advance,
Hank Anzis

Surrogate

Hi, Hank !
this code drop connector named Universal connector from stencil named Connectors, on my side I have this stencil open with my document.
Sub Macro1()
Dim con As Shape, sh1 As Shape, sh2 As Shape
Set sh1 = ActiveWindow.Page.Shapes.ItemFromID(1) ' 1st shape with ID=1
Set sh2 = ActiveWindow.Page.Shapes.ItemFromID(5) ' 2nd shape with ID=5
Set con = ActiveWindow.Page.Drop(Application.Documents.Item("CONNEC_M.vssx").Masters.ItemU("Universal connector"), 0, 0)
Dim conBegin As Visio.Cell
Dim sh1ConPnt As Visio.Cell
Set conBegin = con.CellsU("BeginX") ' begin of connector
Set sh1ConPnt = sh1.CellsSRC(7, 0, 0) ' connection point on sh1
conBegin.GlueTo sh1ConPnt
Dim conEnd As Visio.Cell
Dim sh2ConPnt As Visio.Cell
Set conEnd = con.CellsU("EndX") ' end of connector
Set sh2ConPnt = sh2.CellsSRC(7, 0, 0) ' connection point on sh2
conEnd.GlueTo sh2ConPnt
End Sub


HankAnzis

Thanks for your help! I used the link provided in the second reply to try to select the connector via keystrokes (I am automating through a c# app). If I find a way to programatically select the connector I will post it here.

Regards,
Hank Anzis