PDA

View Full Version : Solved: Excel 2003 How can I delete a specific shape type within the ActiveSheet



frank_m
12-12-2010, 10:18 PM
I wrote this Macro to create a msoShapeCross and position it relative to column 9 on the active row.

It works fine, however now I need the proper command that will delete only the shapes on the sheet that are of this same type (msoShapeCross)

Thanks :help
Sub Macro4()

Dim LeftPos As Integer
Dim TopPos As Integer
Dim intWidth As Integer
Dim intHeight As Integer


TopPos = ActiveCell.Offset(0, 9 - ActiveCell.Column).Top
intWidth = 18
intHeight = 18
LeftPos = ActiveCell.Offset(0, 9 - ActiveCell.Column).Left

Dim sh As Shape

Set sh = ThisWorkbook.Worksheets("Tool_Log").Shapes.AddShape(msoShapeCross, _
LeftPos, TopPos, intWidth, intHeight)

With sh
.Placement = xlFreeFloating
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = 10
.OnAction = "MyMacro"
End With

End Sub

Bob Phillips
12-13-2010, 01:37 AM
Sub DeleteCrosses()
Dim shp As Shape

For Each shp In ActiveSheet.Shapes

If shp.AutoShapeType = msoShapeCross Then

shp.Delete
End If
Next shp
End Sub

frank_m
12-13-2010, 06:17 AM
Thanks xld, your code works nicely :thumb