V2KDSG Support:
GlueTo Anomaly, not gluing
Home Visio V2KDSG V2KDSG Support This page

Glue and Connectors are complicated enough that often people hit odd situations which may just be not following the "right way". Other times they really are anomalies in Visio behavior. In case this example helps someone else...

DD reported: When I drop a 2d shape on the page, I want a 1d connector to connect (dynamic connection) this shape to another shape already on the screen.  What happens is that the 1d shape will drop on the screen, but does not connect to the two 2d shapes. The endpoints are red and look as if they are connected to something. If I move one of the 2d shapes near the dropped connector, then it will connect. And, if I watch the page while stepping through the VBA code, everything works as it should. Does anyone know a work around for this problem?  Sample code:

Public Sub AddAConnection(shpObj As Visio.Shape)

Dim objDriverGroup As Visio.Shape
Dim objNewConnectorMaster As Master
Dim objNewConnector As Shape
Dim objGlueFromBegin As Cell
Dim objGlueFromEnd As Cell
Dim objMyPage As Visio.Page
  On Error GoTo errHandler

  Set objMyPage = ActivePage
  Set objNewConnectorMaster =
  ActiveDocument.Application.Documents.Item("ObjectStencil.vss").Masters.Item("Link")
  Set objDriverGroup = shpObj

  Set objNewConnector = objMyPage.Drop(objNewConnectorMaster,
  objDriverGroup.Cells("PinX"), _
  objDriverGroup.Cells("PinY"))

  Set objGlueFromBegin = objNewConnector.Cells("BeginX")
  Set objGlueFromEnd = objNewConnector.Cells("EndX")

  objGlueFromEnd.GlueTo ActivePage.Shapes(2).Cells("PinX")
  objGlueFromBegin.GlueTo objDriverGroup.Cells("PinX")
  Exit Sub
errHandler:
  MsgBox "Error " + err.Description + " " + Str(err.Number) + " " + err.Source
End Sub

KW reported on some related tests, breaking these steps down a bit more, worked just fine.

DD later responded: Well, it turns out that a strategically placed DoEvents, after the drop, fixed the problem.


Article Created: 2000-08-14 Last edit: Last edit: 00-09-06 Graham Wideman
Go to:
  DiagramAntics.com