Changing shapes

T

T

How do I change shapes in an audit flowchart without deleting the old shape and pulling in a new one? In Powerpoint, you can change the shape at the click of a mouse, but I can't seem to find that capability in Visio.
 
D

David Parker

Shapes in Visio are far more complex than those in PowerPoint. There is no
simple "replace selected shape with another" capability.

The shapes have to be programmed to have the change behaviour. See the
"flowchart shapes" master near the bottom of the "Basic Flowchart Shapes"
stencil. It has 4 different appearance options, but in reality, they are
all contained within the same shape.
Similarly, the Organization Chart shapes have this capability built-in.

If you are using similar shapes, and you connect them dynamically, then the
following VBA code will work:

Public Sub SwapShapes()
'Purpose : Enable Simple Swapping of Similar Shapes
'Usage : Drop the desired new shape near the old shape, then select the old
shape and the new shape (in that order), then run this code
'
Dim shpOld As Visio.Shape
Dim shpNew As Visio.Shape
Dim cnx As Visio.Connect
Dim i As Integer

If Not Visio.ActiveWindow.Selection.Count = 2 Then
'Abort if there are not 2 shapes selected
Exit Sub
Else
Set shpOld = Visio.ActiveWindow.Selection.Item(1)
Set shpNew = Visio.ActiveWindow.Selection.Item(2)
End If

If Not shpOld.OneD = 0 Or Not shpNew.OneD = 0 Then
'Abort if either is a connector line
Exit Sub
End If

'Change connections to new shape
For Each cnx In shpOld.FromConnects
cnx.FromCell.GlueTo shpNew.CellsSRC(cnx.ToCell.Section,
cnx.ToCell.Row, cnx.ToCell.Column)
Next cnx

'Set the text
shpNew.Text = shpOld.Text
'Set the position of the new shape
shpNew.Cells("PinX").Formula = shpOld.Cells("PinX").Formula
shpNew.Cells("PinY").Formula = shpOld.Cells("PinY").Formula
'Set the size of the new shape
shpNew.Cells("Width").Formula = shpOld.Cells("Width").Formula
shpNew.Cells("Height").Formula = shpOld.Cells("Height").Formula
'Delete the old shape
shpOld.Delete

End Sub

If you are using custom properties, etc, then you will have to amend the
code

T said:
How do I change shapes in an audit flowchart without deleting the old
shape and pulling in a new one? In Powerpoint, you can change the shape at
the click of a mouse, but I can't seem to find that capability in Visio.
 

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