Removing All Shapes or objects on a layer

G

Gary

Can someone show me how to remove all shapes or objects (i.e. cirlces, lines,
letters, etc.) on a given visio layer??

I currently have 4 layers. There are a few common shapes that is not
assiciated with any given layer. They are the same shapes or objects on each
of the visio drawing. I want the abiity to clear everything from my visio
drawing that is not on a given layer and that is not associated with any
layer.

Can someone help me here???


Thank You,

Gary
Thanks,
Gary
 
A

Al Edlund

you might wrap some of this in a
for each shape on page.shapes

next shape

Al

'*********************************************************************

'*********************************************************************

'

' Add and Remove Shape From Layer

'

'*********************************************************************

'*********************************************************************

Public Sub RemoveShapeFromLayer _

(ByVal visPage As Visio.Page, _

ByVal visShape As Visio.Shape, _

ByVal strLayer As String, _

ByVal shortPreserve As Short)

Dim existingLayers As Microsoft.Office.Interop.Visio.Layers

Dim addedLayer As Microsoft.Office.Interop.Visio.Layer

Try

' get a list of the layers on the page

existingLayers = CType(visPage.Layers, _

Microsoft.Office.Interop.Visio.Layers)

addedLayer = CType(existingLayers.ItemU(strLayer), _

Microsoft.Office.Interop.Visio.Layer)

addedLayer.Remove(visShape, shortPreserve)

Catch err As Exception

Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only
Policy")

If (rethrow) Then

Throw

End If

End Try



End Sub

Public Sub AddShapeToLayer _

(ByVal visPage As Visio.Page, _

ByVal visShape As Visio.Shape, _

ByVal strLayer As String, _

ByVal shortPreserve As Short)

Dim existingLayers As Microsoft.Office.Interop.Visio.Layers

Dim addedLayer As Microsoft.Office.Interop.Visio.Layer

Try

' get a list of the layers on the page

existingLayers = CType(visPage.Layers, _

Microsoft.Office.Interop.Visio.Layers)

addedLayer = CType(existingLayers.ItemU(strLayer), _

Microsoft.Office.Interop.Visio.Layer)

addedLayer.Add(visShape, shortPreserve)

Catch err As Exception

Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only
Policy")

If (rethrow) Then

Throw

End If

End Try

End Sub
 
G

Gary

I am a little lost with this!

If made a given layer visible and did a SelectAll, that will select all of
the objects. Since I always know the object that are placed on NO LAYERS, I
could manually do a DeselectAll of those objects, follow that with
Selection.Delete??? Will this remove all of the objects on the layer except
those that are not?????
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top