PC Review


Reply
Thread Tools Rate Thread

Code to Remove Form Control buttons Q

 
 
Seanie
Guest
Posts: n/a
 
      11th Jul 2010
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
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      11th Jul 2010
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
 
Reply With Quote
 
Seanie
Guest
Posts: n/a
 
      12th Jul 2010
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
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      12th Jul 2010
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: No Change/Remove buttons in the Add/Remove part of the Control Panel James Finch Windows XP Hardware 0 28th Oct 2008 11:00 PM
RE: No Remove/Change buttons in the Control Panel's Add/Remove feature Leonard Grey Windows XP Help 1 18th Oct 2008 12:28 AM
Form buttons and Control Command Buttons ranswrt Microsoft Excel Programming 0 7th Aug 2008 11:36 PM
No buttons in Add/Remove Control Panel bill@dwyer.ws Windows XP General 2 24th Apr 2006 08:47 PM
How to remove the control box, close, min max buttons =?Utf-8?B?QW5nZWwgYjE=?= Microsoft Access Forms 4 28th Dec 2004 03:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:20 AM.