Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default Code to Remove Form Control buttons Q

I have the code below which removes Form Control buttons, but it also
removes Charts I have on the sheet, how can I adjust the code below,
which will allow me to still remove the buttons but not the Charts?


Sub ClearMacroButtons()

On Error Resume Next
Sheets("Report").Select
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete
On Error GoTo 0
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Code to Remove Form Control buttons Q

If the buttons are from the Forms toolbar, you could use:

Dim BTN as button
for each btn in worksheets("report").buttons
btn.delete
next btn


If the commandbuttons are from the Control toolbox toolbar, you could use:

Dim OLEObj As OLEObject
For Each OLEObj In Worksheets("report").OLEObjects
If TypeOf OLEObj.Object Is MSForms.commandbutton Then
OLEObj.Delete
End If
Next OLEObj


On 07/11/2010 10:40, Seanie wrote:
I have the code below which removes Form Control buttons, but it also
removes Charts I have on the sheet, how can I adjust the code below,
which will allow me to still remove the buttons but not the Charts?


Sub ClearMacroButtons()

On Error Resume Next
Sheets("Report").Select
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete
On Error GoTo 0
End Sub


--
Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default Code to Remove Form Control buttons Q

Thanks works like a dream, but how do I tweak to work through several
sheet? My existing code is

Sub ClearMacroButtons()

On Error Resume Next
Sheets(Array("E-Mail1", "E-Mail2", "E-Mail3", "E-Mail4", "E-
Mail5")).Select
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete

On Error GoTo 0
End Sub

I tried, but it debugs

Sub ClearMacroButtons()
Dim BTN as button
for each btn in Sheets(Array("E-Mail1", "E-Mail2", "E-Mail3", "E-
Mail4", "E-Mail5")).buttons
btn.delete
next btn
End Sub
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Code to Remove Form Control buttons Q

Option Explicit
Sub ClearMacroButtons()
Dim WksNames As Variant
Dim BTN As Button
Dim wCtr As Long

WksNames = Array("E-Mail1", "E-Mail2", "E-Mail3", "E-Mail4", "E-Mail5")

For wCtr = LBound(WksNames) To UBound(WksNames)
For Each BTN In Worksheets(WksNames(wCtr)).Buttons
BTN.Delete
Next BTN
Next wCtr

End Sub



On 07/12/2010 01:08, Seanie wrote:
Thanks works like a dream, but how do I tweak to work through several
sheet? My existing code is

Sub ClearMacroButtons()

On Error Resume Next
Sheets(Array("E-Mail1", "E-Mail2", "E-Mail3", "E-Mail4", "E-
Mail5")).Select
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete

On Error GoTo 0
End Sub

I tried, but it debugs

Sub ClearMacroButtons()
Dim BTN as button
for each btn in Sheets(Array("E-Mail1", "E-Mail2", "E-Mail3", "E-
Mail4", "E-Mail5")).buttons
btn.delete
next btn
End Sub


--
Dave Peterson
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
Using Multiple sets of Option Buttons (Form Control) In Excell Michael Hudston Excel Worksheet Functions 2 February 26th 09 08:07 AM
Form buttons and Control Command Buttons ranswrt Excel Programming 0 August 7th 08 11:36 PM
Form Buttons Connected to a Macro - Want to remove the button Wksht Excel Worksheet Functions 2 June 13th 07 06:58 PM
how to delete or remove checkbox form control in Excel? tubbekans Excel Discussion (Misc queries) 1 December 14th 05 08:51 PM
How do I create a form in a worksheet with control option buttons. andreah New Users to Excel 2 April 23rd 05 01:12 AM


All times are GMT +1. The time now is 07:59 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"