Deleting ActiveX control???

D

Dr.Ile

Hello?

I have a problem with deleting ActiveX CommandButton control. Actualy I
don't want to delete them. Here is an example:

1) First I draw CommandButton control from Control Toolbox and then
assign him a macro...
2) Then I draw a few drawing objects (Line, Rectangle)...
3) Then I write a procedure where I want to delete this drawing objects
(Line, Rectangle) with

...
Worksheets(1).Shapes.SelectAll
Selection.Delete
...

4) Now I run this procedure which delete all drawing objects (Line,
Rectangle) and also CommandButton control.

Can I lock or do something else to prevent deleting CommandButton.

Thank you
 
N

Norman Jones

Hi Dr. Ile,

Try:

'=============>>
Public Sub Tester002()
Dim SHP As Shape

For Each SHP In ActiveSheet.Shapes
If Not SHP.Type = 12 Then
SHP.Delete
End If
Next SHP

End Sub
'<<=============
 

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