Ok, it seems to me like it takes a while, I have a few hundred shapes.
I got about 100 different boxes and stuff, that I'm showing all of the time,
what I'm switching on/off is their connectors , and datagraphics for both
connectors, and all the other shapes.
I'm not sure what you mean by this:
"> Individual macros have an overhead for Undo and setting up document
references so re-writing the macros might be worth while."
Are you talking about references to objects in my diagram, like shapes and
layers?
In the beginning of the function I save the reference for the layer I'm
working with, and I then save the individual shapes and the layers they are
part of, while iterating through it all (only on shape and one layer saved at
the time), I'm not sure I can put down the reference count any.
Paul Herber said:
On Mon, 4 Aug 2008 04:13:00 -0700, jarlen
That is the normal, correct way to do it,, however, iterating through
the shapes shouldn't take too long, even with hundreds of shapes on a
page.
Another way would be to make all layers invisble except for the
required layer(s), then select all shapes and iterate through the
selection.
Individual macros have an overhead for Undo and setting up document
references so re-writing the macros might be worth while.
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 =
Application.ActiveWindow.Page.CreateSelection(visSelTypeByLayer,
visSelModeSkipSuper, "RedShapes")
For Each vShp In vsoSelection1
vShp.Name = 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
"container"
Here's an example of a Group being a Shape that is also a container of
Shapes:
For Each vShape In grpShape.Shapes
shapeNum = vShape.Name
vShape.CellsSRC(Visio.visSectionUser, 2, visUserValue) =
modelVars(shapeNum).Activity
vShape.DataGraphic = 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