Lock relative position between several shapes

M

Martin R

I want to be able to lock the relative position between two or more shapes.
To group the shapes are not a good solution for me, since I want to be able
to change the text in the shapes without ungrouping.
 
A

Al Edlund

you do of course realize that you can change text without ungrouping?

regarding the locking of positions, David Edson has an example in his book
("Professional Development With Visio 2000") which is called Associate.VSD
which shows one way of doing it.

Al
 
J

junethesecond

You can chage the text in the shapes in a group.

1. select a group.
2. select a shape in the group.
3. press text tool button.
4. change text in the shape.
5. select another shape in the group.
6. change text.
 
J

junethesecond

Another idea is to make macro.
The macro writes forumla to lock
relative position in pinx and
piny cells of sheet.2.

The formula may be as,
GUARD(Sheet.1!PinX+a in)
GUARD(Sheet.1!PinY+b in)),
where a,b are relative position
of shapes, sheet.1 and sheet.2.
 
Z

zacharias

Thanks for your response!

I am aware that it is possible to change the text by using the text tool,
but that is not very efficient due to how I use Visio at my work. Another
reason why I do not want to use the grouping is because I want to have the
different shapes in different layers.

I'll check the book.

Thanks
"Al Edlund" skrev:
 
M

Martin R

As I answered in my colleague Zacharias name:

Thanks for your response!

I am aware that it is possible to change the text by using the text tool,
but that is not very efficient due to how I use Visio at my work. Another
reason why I do not want to use the grouping is because I want to have the
different shapes in different layers.

Is the book you are refering to relevant for Visio 2003 as well?

Thanks


"Al Edlund" skrev:
 
M

Martin R

I start to realise that I have to take that way to get what I want. Can you
recommend any good book for Visio VBA?

"junethesecond" skrev:
 
J

John Marshall, MVP

There are two main books for learning VBA with Visio and only one for the
advanced user.

1.) Developing Visio Solutions has been the main book from Visio on how to
create shapes and do automation. It was last released for Visio 2002, but
the basic information has not changed over the versions (but it has been
enhanced)
2.) Dave Edson's book was written for Visio 2000, but it does have some
excellent examples.

3) for the advanced - any version of Graham Wideman's book.

For more information see the Book section at:
http://www.mvps.org/visio/Information_Sites.htm

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
 
M

Martin R

Thanks Mark,

It works fine use predefined layers on the shapes and using the texttool to
change the text in the different shapes within the group. However, I'm
working as a consultant and are often mapping processes. Then, I'm using
Visio and normally the customer sits beside me which requires a very
efficient working procedure. To speed up my work I do not want to use the
texttool and I do not want to ungroup and then group again if I for instance
want to change the size of one of the shapes. If I ungroup and change the
size, then the relative position to the other shapes are changed, and I need
to rearrange the shapes again before I group again.

Therefore, to be able to lock the relative position between different shapes
would ease up and speed up my work significantly. Is a macro the only way to
do it?

Thanks
/Martin
 
M

Martin R

To further clarify my request, I want to be able to select two or more shapes
and then press a button to lock their relative position. You are in Visio
able to lock for instance x and y-position and proportions but not relative
position to another shape.
 
J

junethesecond

You can make a program to lock
the shapes you selected
by means of
GUARD(Sheet.1!PinX+a in)
GUARD(Sheet.1!PinY+b in).

But one more idea is needed,
because a set of locked shapes
don't move, if you don't move
the shape, sheet.1.
 
J

junethesecond

This is the sample,
but may have many problems.

Option Explicit

Private Assemble As Collection
Private FillColor As Long

Sub LockRelativePosition()
Dim shp1 As Visio.Shape, shpA As Visio.Shape
Dim I As Long, N As Long
Dim MySelection As Selection
Dim DeltaX As Double, DeltaY As Double
Set Assemble = New Collection
Set MySelection = ActiveWindow.Selection
Set shp1 = MySelection(1)
FillColor = shp1.Cells("FillForegnd")
shp1.Cells("FillForegnd") = 2
Assemble.Add shp1
N = MySelection.Count
For I = 2 To N
Set shpA = MySelection(I)
Assemble.Add shpA
DeltaX = shpA.Cells("PinX") - shp1.Cells("PinX")
DeltaY = shpA.Cells("PinY") - shp1.Cells("PinY")

shpA.Cells("PinX").Formula = "GUARD(" & shp1.Name & "!PinX+" &
DeltaX & ")"
shpA.Cells("PinY").Formula = "GUARD(" & shp1.Name & "!PinY+" &
DeltaY & ")"
Next
End Sub

Sub UnLockRelativePosition()
Dim shp1 As Visio.Shape, shpA As Visio.Shape
Dim I As Long, N As Long
Dim DeltaX As Double, DeltaY As Double
N = Assemble.Count
Set shp1 = Assemble(1)
shp1.Cells("FillForegnd") = FillColor
For I = 2 To N
Set shpA = Assemble(I)
DeltaX = shpA.Cells("PinX") - shp1.Cells("PinX")
DeltaY = shpA.Cells("PinY") - shp1.Cells("PinY")

shpA.Cells("PinX").FormulaForce = shp1.Cells("PinX") + DeltaX
shpA.Cells("PinY").FormulaForce = shp1.Cells("PinY") + DeltaY
Next
End Sub
 
M

Martin R

Thanks a lot!

There were some problems in the code, but I've ordered the Edson book and I
will hopefully be able to solve the problems.

"junethesecond" skrev:
 
M

Martin R

Hi,

Unfortunately the book you are refering to is unavailable at all sites I've
visited. Can you recommend any other book or help me were I can get hold of
the example in the book?

"Al Edlund" skrev:
 

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