Layer.Add Method
Visio Automation Reference |
Adds a Shape object to a Layer object.
Version Information
Version Added: Visio 2.0
Syntax
expression.Add(SheetObject, fPresMems)
expression A variable that represents a Layer object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
SheetObject | Required | [IVSHAPE] | The new Shape object added to the Layer object. |
fPresMems | Required | Integer | Zero to remove subshapes from any previous layer assignments; non-zero to preserve layer assignments. |
Return Value
Nothing
Remarks
If the shape is a group and fPresMems is non-zero, the component shapes of the group retain their current layer assignments and are also added to this layer. If fPresMems is zero, the component shapes are reassigned to this layer and lose their current layer assignments.
Example
The following example shows how to use the Add method to add Shape objects to a Layer object. When the Shape object you add to a Layer object is a group shape, use the fPresMems argument of the Add method to specify whether the component shapes of the group retain or lose their previous layer assignments. If the shape you add is not a group shape, the fPresMems argument has no effect, but is still required.
In the example, two new layers are created. Two rectangle shapes are drawn and then added to the first layer. Subsequently, the rectangles are grouped into a group shape. The group shape is then selected and duplicated, and the duplicate group shapes are added to the second layer in two different ways.
Layer assignments of the component shapes of vsoShapeGroup2 are retained by passing a non-zero value for the fPresMems argument of the Add method, but previous layer assignments of the component shapes of vsoShapeGroup1 are lost when zero is passed to the Add method for that argument. As a result, the component shapes of vsoShapeGroup1 are assigned only to vsoLayer2, while the components of vsoShapeGroup2 are assigned to both vsoLayer1 and vsoLayer2.
Visual Basic for Applications |
---|
|
See Also