Remove buttons from worksheet programmatically

A

Albert Browne

Hi.

I have a number of worksheets that I copy to a new workbook. These
worksheets have a number of command buttons. I would like to remove these
buttons after copying. Is this possible with VBA?


Thanks.

Albert
 
W

WhytheQ

Try this Albert:

'====================
Sub DeleteAllButtons()

Dim mySheet As Worksheet
Dim MyButton As OLEObject

For Each mySheet In ActiveWorkbook.Worksheets

For Each MyButton In mySheet.OLEObjects
If TypeOf MyButton.Object Is MSForms.CommandButton Then
MyButton.Delete
End If
Next MyButton

Next mySheet

End Sub
'====================
 
Top