Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Remove all Button

Status
Not open for further replies.

bont

Programmer
Sep 7, 2000
200
US
I am using a macro to add an OLEOBJECT form.commandbutton.

I have added a few, but can't figure out how to remove them.

Does anyone know how to cycle throughout all of them in a sheet, and delete them all?

Does anyone know a good reference for this?

Here is the code used to add them:

Set Btn = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, left:=d_left, top:=d_top, width:=d_width, height:= _
d_height)
 
Something like this should work:
Dim Olo As OLEObject
For Each Olo In Me.OLEObjects
If Olo.ProgId = "Forms.Commanbutton.1" Then
Olo.delete
End If
Next Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Thank you very much. I did have to alter it as such:

Dim Olo As OLEObject
For Each Olo In ActiveSheet.OLEObjects
If Olo.progID = "Forms.CommandButton.1" Then
Olo.Delete
End If
Next

It threw me for a while :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top