Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Delete all commandbuttons in workbook

Is there a way to delete all the commandbuttons in the entire
workbook? I found some code below that does it for a single sheet.
Thanks!

Sub DeleteCommandButtons()
Dim Obj As OLEObject
For Each Obj In ActiveSheet.OLEObjects
If Obj.progID = "Forms.CommandButton.1" Then
Obj.Delete
End If
Next Obj
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete all commandbuttons in workbook

Hi steve

Sub OLEObjects3()
'Delete/hide only all CommandButtons from the Control Toolbox
Dim obj As OLEObject
Dim sh As Worksheet

For Each sh In ActiveWorkbook.Worksheets
For Each obj In sh.OLEObjects
If TypeOf obj.Object Is MSForms.CommandButton Then
obj.Delete
' or obj.Visible = False if you want to hide them
End If
Next
Next sh
End Sub


See also
http://www.rondebruin.nl/controlsobjectsworksheet.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Steve" wrote in message ...
Is there a way to delete all the commandbuttons in the entire
workbook? I found some code below that does it for a single sheet.
Thanks!

Sub DeleteCommandButtons()
Dim Obj As OLEObject
For Each Obj In ActiveSheet.OLEObjects
If Obj.progID = "Forms.CommandButton.1" Then
Obj.Delete
End If
Next Obj
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Delete a Range in Closed Workbook (to Replace Delete Query) [email protected] Excel Discussion (Misc queries) 1 March 8th 06 10:10 AM
CommandButtons Mats Samson Excel Programming 4 January 17th 06 02:19 PM
Commandbuttons PCOR Excel Programming 1 May 11th 04 11:21 PM
delete commandbuttons on copied sheet qerj Excel Programming 6 February 16th 04 01:18 PM
commandbuttons properties Rui[_2_] Excel Programming 2 November 5th 03 04:07 PM


All times are GMT +1. The time now is 03:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"