me,
d
re
d at
t of
gram
is
now is
they
Doing
do
co.uk/
I've been away from Visio for a while. But I was able to dig out a
couple of examples for you. Here's one in which the Shapes associated
with a Layer are Selected:
Sub ShapesInLayer()
Dim vShp As Shape
Dim vsoSelection1 As Visio.Selection
' RedShapes is the name of th e Layer
Set vsoSelection1 =3D
Application.ActiveWindow.Page.CreateSelection(visSelTypeByLayer,
visSelModeSkipSuper, "RedShapes")
For Each vShp In vsoSelection1
vShp.Name =3D vShp.CellsSRC(Visio.visSectionProp, 0,
visCustPropsValue)
Debug.Print vShp.Name & " " & vShp.NameU
Next
End Sub
In the above case the technique is to use a Selection as the Shape
Here's an example of a Group being a Shape that is also a container of
Shapes:
For Each vShape In grpShape.Shapes
shapeNum =3D vShape.Name
vShape.CellsSRC(Visio.visSectionUser, 2, visUserValue) =3D
modelVars(shapeNum).Activity
vShape.DataGraphic =3D ActiveDocument.Masters("DG_IsBasic")
Next
A lot of good sample code can be found here:
http://visio.mvps.org/VBA.htm
Note that at that site, there are 2 examples of selecting Shapes in a
Layer. The first one doesn't work properly.
Also note that a DataGraphic is NOT explicitly assigned to a Layer
with its parent Shape. So if you cycle through a Layer to hide the
Shapes, the DataGraphic Objects will remain on the screen. So when
you cycle through the Shapes, you must also set the Shape DataGraphic
to Nothing.
Lastly, the are many ways to do things in Visio. Different guys have
different methods. Given that the Visio Help System stinks, I think
most guys do trial and error until they got something that works and
then stick with it.
'SteveM