Hiding DataGraphics in a Layer

S

SteveM

If I use code to hide a shape that has visible DataGraphics, the shape
is hidden but the DataGraphics remain exposed. Is there a standard
method for hiding/exposing both the shapes in a layer and the
associated DataGraphics?

Thanks,

SteveM
 
M

Michel LAPLANE \(MVP\)

Well as datagraphics are shapes you have to affect the data graphics to the
same layers that is not so
beautiful because of the number of shapes that can be in the datagraphics.
I think the best way is to create an empty datagraphics and affect it to
you shape when your layer is hidden.
Not so conventional but.

Enjoy with Visio.
 
S

SteveM

Well as datagraphics are shapes you have to affect the data graphics to the
same layers that is not so
beautiful because of the number of shapes that can be in the datagraphics.
I think the best way is to create an empty datagraphics and affect it to
you shape when your layer is hidden.
Not so conventional but.

Enjoy with Visio.

Michel,

I though about trying to assign a Datagraphic to something other than
its default layer. But it's not clear to me how to do that. Is that
what your meant?

What I'm doing now when I use code to hide a layer is to also cycle
though each shape in the layer and set its DataGraphic to Nothing.
That works, but I was thinking about something more elegant.

Can you elaborate briefly on your idea?

Thanks,

SteveM
 
C

Chris Roth [Visio MVP]

Hi Steve,

I noticed that if you apply a layer to a shape *after* a data graphic is
applied, then the data graphic will take the layer.

This works even if you "re-apply" the layer. (ie: Shape > Layer, do
nothing but click OK -- effectively re-applying the same layer(s) to the
shape)

But if you look at the macro-recorder code, you'll see that Visio did
indeed loop through all the shapes and sub-shapes and apply the "new"
layer to the shape, which is probably what you were trying to avoid.

You might try something like making a formula in the data graphic that
refers to the group's LayerMember cell. The formula would look like this:

(for the data graphic)
LayerMember = Sheet.5!LayerMember
(sheet.5 is the group)

In code, it might go something like this:

dgShp.Cells("LayerMember").Formula =
dgShp.ContainingShape.NameID & "!LayerMember"

--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People
http://www.visguy.com
 
S

SteveM

Hi Steve,

I noticed that if you apply a layer to a shape *after* a data graphic is
applied, then the data graphic will take the layer.

This works even if you "re-apply" the layer. (ie: Shape > Layer, do
nothing but click OK -- effectively re-applying the same layer(s) to the
shape)

But if you look at the macro-recorder code, you'll see that Visio did
indeed loop through all the shapes and sub-shapes and apply the "new"
layer to the shape, which is probably what you were trying to avoid.

You might try something like making a formula in the data graphic that
refers to the group's LayerMember cell. The formula would look like this:

(for the data graphic)
LayerMember = Sheet.5!LayerMember
(sheet.5 is the group)

In code, it might go something like this:

dgShp.Cells("LayerMember").Formula =
dgShp.ContainingShape.NameID & "!LayerMember"

--
Hope this helps,

Chris Roth
Visio MVP

Visio Guy: Smart Graphics for Visual People
http://www.visguy.com

Chris,

Thanks, I tried it and I see what you are saying. The trivial
solution only works though for the active Data Graphic. I plan on
toggle through multiple DG's for a shape to show different
information. But that's OK, at least now I know and can live with
visibility management by code.

I have to look at your DG formula solution. I've tried playing with
the feature more generally and have not figured out how it works. And
can't find any documentation. Any help there would be great.

Thanks,

SteveM
 

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