Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Deleting a Button on a Worksheet

Hi

I have had trouble with some code to remove the macro button from a
worksheet (the spreadsheet is being reduced to bare values etc for
distribution as a final report etc)

By way of background, the workbook has been used by others so someone may
have copied or reinstated the macro button - see below.

I was using this code:
ActiveWorkbook.Sheets("Income & Expenditure A1").Shapes("Button 3").Delete
but I have recently got the runtime error "the item with the specified name
was not found"

I substituted this code and it seems to work OK
ActiveWorkbook.Sheets("Income & Expenditure A1").Shapes(1).Delete

My question is this: will this code ALWAYS delete the one macro button on
the sheet (there are no other "shapes").

Many thanks

Tim



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Deleting a Button on a Worksheet

You can use this to delete all shapes

Sub Shapes1()
'Delete all Objects except Comments
On Error Resume Next
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete
On Error GoTo 0
End Sub


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


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Tim Childs" wrote in message ...
Hi

I have had trouble with some code to remove the macro button from a
worksheet (the spreadsheet is being reduced to bare values etc for
distribution as a final report etc)

By way of background, the workbook has been used by others so someone may
have copied or reinstated the macro button - see below.

I was using this code:
ActiveWorkbook.Sheets("Income & Expenditure A1").Shapes("Button 3").Delete
but I have recently got the runtime error "the item with the specified name
was not found"

I substituted this code and it seems to work OK
ActiveWorkbook.Sheets("Income & Expenditure A1").Shapes(1).Delete

My question is this: will this code ALWAYS delete the one macro button on
the sheet (there are no other "shapes").

Many thanks

Tim





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Deleting a Button on a Worksheet

Ron

That was really helpful - thanks

Given that I want to remove any buttons I used one of the tips on the link
to your site:
ActiveSheet.Buttons.Delete

vbw

Tim

"Ron de Bruin" wrote in message
...
You can use this to delete all shapes

Sub Shapes1()
'Delete all Objects except Comments
On Error Resume Next
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete
On Error GoTo 0
End Sub


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


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Tim Childs" wrote in message

...
Hi

I have had trouble with some code to remove the macro button from a
worksheet (the spreadsheet is being reduced to bare values etc for
distribution as a final report etc)

By way of background, the workbook has been used by others so someone

may
have copied or reinstated the macro button - see below.

I was using this code:
ActiveWorkbook.Sheets("Income & Expenditure A1").Shapes("Button

3").Delete
but I have recently got the runtime error "the item with the specified

name
was not found"

I substituted this code and it seems to work OK
ActiveWorkbook.Sheets("Income & Expenditure A1").Shapes(1).Delete

My question is this: will this code ALWAYS delete the one macro button

on
the sheet (there are no other "shapes").

Many thanks

Tim







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
Deleting a Command Button Tdahlman Excel Discussion (Misc queries) 3 December 20th 07 08:34 PM
Deleting a Command Button from my Spreadsheet DDrowe Excel Discussion (Misc queries) 2 November 7th 06 01:49 PM
deleting values in a worksheet without deleting the formulas patti Excel Worksheet Functions 1 October 28th 05 09:49 PM
Deleting a button Johnny Bright Excel Programming 4 February 14th 05 08:13 PM
Deleting Command Button James W.[_2_] Excel Programming 0 January 11th 05 08:19 PM


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