Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Delete a command button via VBA

Is there a way to delete a command button? I have an excel template file
with multiple sheets. We have older files that are older revisions. I want
the user to open the template file and open an old file. On the template
file, I have a button that will open a user form showing the open excel
files so that they can select the desired file and it will copy the
appropriate data from the old file to the new template, rename the old file,
and save the template with the name of the old file. I wanted to delete the
command button so that it will only appear on the template instead of every
file. I guess that I could hide the button based on a value that I place on
the sheet, but I figured that I would just try to remove it.

Thanks,
Brian


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete a command button via VBA

Dim obj as OleObject
for each obj on Activesheet.OleObjects
if type of obj.Object is MSForms.CommandButton
then obj.Delete
end if
Next

if you only have one shape on the sheet (no autofilter dropdowns or other
shapes)

ActiveSheet.Shapes(1).Delete

this should help you find the best solution for you.

--
Regards,
Tom Ogilvy

"Brian K. Sheperd" wrote in message
...
Is there a way to delete a command button? I have an excel template file
with multiple sheets. We have older files that are older revisions. I

want
the user to open the template file and open an old file. On the template
file, I have a button that will open a user form showing the open excel
files so that they can select the desired file and it will copy the
appropriate data from the old file to the new template, rename the old

file,
and save the template with the name of the old file. I wanted to delete

the
command button so that it will only appear on the template instead of

every
file. I guess that I could hide the button based on a value that I place

on
the sheet, but I figured that I would just try to remove it.

Thanks,
Brian




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Delete a command button via VBA

Tom,
Thank you. I will give it a shot.
Thanks,
Brian

"Tom Ogilvy" wrote in message
...
Dim obj as OleObject
for each obj on Activesheet.OleObjects
if type of obj.Object is MSForms.CommandButton
then obj.Delete
end if
Next

if you only have one shape on the sheet (no autofilter dropdowns or other
shapes)

ActiveSheet.Shapes(1).Delete

this should help you find the best solution for you.

--
Regards,
Tom Ogilvy

"Brian K. Sheperd" wrote in message
...
Is there a way to delete a command button? I have an excel template

file
with multiple sheets. We have older files that are older revisions. I

want
the user to open the template file and open an old file. On the

template
file, I have a button that will open a user form showing the open excel
files so that they can select the desired file and it will copy the
appropriate data from the old file to the new template, rename the old

file,
and save the template with the name of the old file. I wanted to delete

the
command button so that it will only appear on the template instead of

every
file. I guess that I could hide the button based on a value that I

place
on
the sheet, but I figured that I would just try to remove it.

Thanks,
Brian






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
Delete with command button? John[_100_] Excel Programming 3 March 17th 05 01:38 PM
Delete command button gavmer[_96_] Excel Programming 0 October 19th 04 12:56 AM
Delete command button BrianB Excel Programming 0 October 18th 04 10:28 AM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM
copy and delete command button Mark Kubicki Excel Programming 0 October 6th 03 08:20 PM


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