Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete all shapes in layer

347 views
Skip to first unread message

Thijs Schoemaker

unread,
May 26, 2004, 5:05:38 AM5/26/04
to
Is it possible to delete all shapes in a variable layer?

Something like:

dim shp as visio.shape
dim layer as visio.layer

for each shp in layer("Name")
shp.delete
next

Any help very much appreciated!

Robert

Chris Roth [ Visio MVP ]

unread,
May 26, 2004, 9:38:11 AM5/26/04
to
The logic is a bit strange, especially since shapes can belong to more than
one layer at a time.

Check this out:

Sub MarkShapesOnBobLayer()

' Add shapes to page. Put some of them on a layer named "Bob"

Dim s As Visio.Shape
Dim i As Integer, j As Integer
Dim lTarget As Visio.Layer, l As Visio.Layer

' This is the layer object in the page:
Set lTarget = ActivePage.Layers.Item("Bob")

For Each s In ActivePage.Shapes

' Check the layers that the shape belongs to:
For j = 0aTo s.LayerCount
Set l = s.Layer(j)
If l.NameU = lTarget.NameU Then s.Text = "Delete me"
Next j

Next

End Sub

Remember that if you really want to delete the shapes in this loop, you
should make a backwards for loop that goes from ActivePage.Shapes.Count to 1
step -1. Then, when you delete shapes, it won't mess up your loop.

--

Hope this helps,

Chris Roth
Visio MVP


"Thijs Schoemaker" <th...@bcd.nl> wrote in message
news:%231r$3$vQEH...@TK2MSFTNGP10.phx.gbl...

David Parker

unread,
Jun 1, 2004, 5:57:23 PM6/1/04
to
The new CreateSelection method could be used to select shapes on a layer,
then you can delete the selection?

"Chris Roth [ Visio MVP ]" <visi...@reallyreallywarmmail.com> wrote in
message news:%23PMxxay...@TK2MSFTNGP10.phx.gbl...

0 new messages