page-related coordinates of a connection point

K

Kati Molnar

I would like to drop a one dimensional second shape on my page and glue it to
the connection point of a first, 2 dimensional shape already on the page so
that the second shape does not lose its original look.

I dropped my second shape to the page- related coordinates (0,0) to start
with.

First, I tried to glue the second shape to my first shape. However, the
other end of the second shape stays glued to its drop point, so it stretches
out my whole page and loses its original shape.

Second, I would like to move my second shape to the connection point now,
hoping that move does not change its shape. I need to figure out the
page-related x,y coordinates of the connection point of the first shape -
that is needed by the move method.

How to do that in VBA?

Kati
 
K

Kati Molnar

I figured out a solution. I share it below.

Kati

*****************************************************
Public Sub ConnectBranchToShape(shape as Visio.Shape)
' Attach a one dimensional branch to the connection point of a shape.

Dim masterBranch As Visio.Master
Dim branch As Visio.shape
Dim branchCell As Visio.cell
Dim shapeCell As Visio.cell

Dim heightS As Integer
Dim xD, yD As Double

' Get the cell representing the connection point.
Set shapeCell = shape.Cells("Connections.X4")

' Calculate the coordinates of the connection point.
' This connection point is at the bottom center of the shape.
' pinx, piny define the left bottom corner of the box containing the shape.
heightS = shape.Cells("height")
xD = shape.Cells("pinx")
yD = shape.Cells("piny") - heightS / 2

' Get the master branch.
Set masterBranch = Application.ActiveDocument.Masters.Item("Branch")

' Drop the branch close to the shape.
Set branch = ActivePage.Drop(masterBranch, xD, yD)

' Get the start of the branch.
Set branchCell = branch.Cells("BeginX")

' Glue the branch to the connection point of the shape.
branchCell.GlueTo shapeCell

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top