Object Model Reference : Classes : L : Layer : Properties : Layer.Shapes |
Property Shapes As Shapes
Member of Layer
The Shapes property returns a collection of all shapes on a specified layer.
The Shapes property returns a read-only value.
The following VBA example deletes the active layer and moves all shapes on the active layer to the next layer on the page.
Sub Test() |
Dim Target As Layer |
Dim s As Shape |
Dim idx As Long |
If ActivePage.Layers.Count = 1 Then |
MsgBox "Cannot delete a single layer" |
End If |
If ActiveLayer.Shapes.Count Then |
idx = 1 ' Determining the index number of the active layer |
For Each Target In ActivePage.Layers |
If Target Is ActiveLayer Then Exit For |
idx = idx + 1 |
Next Target |
' Finding the index number of the target layer |
If idx = 1 Then idx = 2 Else idx = idx - 1 |
Set Target = ActivePage.Layers(idx) |
ActiveDocument.ClearSelection |
ActiveLayer.Shapes.All.AddToSelection |
ActiveSelection.Layer = Target |
End If |
ActiveLayer.Delete |
End Sub |
Copyright 2013 Corel Corporation. All rights reserved.