adding multiple shapes to a layer at once

Started by hanansho, September 11, 2012, 06:47:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hanansho

Hi all, I have a small question.

I have a visio drawing, with many shapes and many layer.
each shape is assigned to multiple layer.

now, i have added a new layer, and i want to add multiple shapes to that layer, without going them over one by one, something like:

"select shapes -> right click -> add to layer" (i know that is not available).

what is the most easy way to do it?

Thanks a lot in advance.

Paul Herber

Select the shapes, then add to layer from the menu (or ribbon)?
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

hanansho

Hi, thanks for answer, but if you mean using the "shape->format" menu, the problem is as follows:

let's say I have 2 shapes, shape 1 and shape 2.
shape 1 is a member of layer A and B.
shape 2 is a member of layer C and D.

Now I want to add them both to layer E, in addition to their current layers.

if I select them both->right click->shape->format->layer, and choose layer E, then the previous info, then both shpaes would be members of layer E, but not A,B,C or D.

if I choose in the layer menu layers A,B,C,D,E, then both shapes would be members of layers A,B,C,D,E and that's not what I want.
what I mean is that after using the layer menu, all selected shapes will be members of the same layers. I would just like them to keep their previous layer configurations, and just add them all to a new layer in one operation. it may seem like a minor issue, but when you have hundreds of shapes, it becomes more important.

BR,

Hanan


Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

robert.cowham

How are you with VBA macros?


Public Sub AddSelnToLayer()
' Add currently selected shapes to a specific layer

   Dim lyrs               As Visio.Layers
    Dim lyr                As Visio.Layer
    Dim blnPreserveMembers      As Boolean

    On Error GoTo Err_Block
       
    ' Get the Layers collection and add a Layer named
    ' "NewLayer" to the collection.
    Set lyrs = Visio.ActivePage.Layers
    Set lyr = lyrs.Add("NewLayer")
   
    ' If blnPreserveMembers is non-zero, the
    ' shapes retain their current layer assignments and are also added to this layer.
    blnPreserveMembers = True
    Dim shp As Visio.Shape
    For Each shp In Visio.ActiveWindow.Selection
        lyr.Add shp, blnPreserveMembers
    Next
   
    Exit Sub
   
Err_Block:
    Debug.Print Err.Description

End Sub

robert.cowham

p.s. Have a free Visio addin which allows you to select multiple shapes by the values contained in their shape data - can be very useful with larger diagrams with lots of different shapes spread around - obvious requirement is that your shapes have shape data though!

http://www.squaremilesystems.com/782-select-by-data-feature-part-of-sms-visio-utils-1-2/