Hello all,
I'm trying to do some playing around with layers in my diagram so that I can hide/show certain shapes based on various conditions. I've been using the Layer.add method to add shapes in the diagram to the desired layer, which works fine, but the shapes are not removed from other layers.
ActivePage.Layers("Invisible Layer").Add shp, 0
According to the description at https://msdn.microsoft.com/en-us/library/office/ff766857.aspx (https://msdn.microsoft.com/en-us/library/office/ff766857.aspx), the second variable for layer.add should be zero to remove subshapes from any previous layer assignments; non-zero to preserve layer assignments. I'm using zero but the shapes are still sticking to the other layers.
Please help if able.
Thank you,
Phillip
See Remarks under the link you provided. That parameter only applies to subshapes of a group, and only if the selected shape is a group. Otherwise, no layer removal, just layer add. To remove, you need the .remove method: https://msdn.microsoft.com/en-us/library/office/ff768462.aspx (https://msdn.microsoft.com/en-us/library/office/ff768462.aspx)
Wapperdude
Well don't I feel stupid. I noticed that the effect worked on groups, but I assumed there was screwy behavior going on since I didn't see that it only works in groups. Thank you sir.
In your code, you could add a loop to remove shape from each layer, then add to desired layer.
Wapperdude