Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What's wrong with this code? It won't run. I am trying to select a .bmp
image on my worksheet and delete it. I also have a command button on the worksheet and don't want to delete that. The button is "Button 55". Thanks, groundhog Sheets("Sheet1").Select ActiveSheet.Shapes.SelectAll ActiveSheet.Shapes("Button 55").Deselect Selection.Delete |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Give this a try...
Sub RemovePictures() Dim shp As Shape For Each shp In ActiveSheet.Shapes If shp.Name < "Button 55" Then shp.Delete Next shp End Sub -- HTH... Jim Thomlinson "groundhog1" wrote: What's wrong with this code? It won't run. I am trying to select a .bmp image on my worksheet and delete it. I also have a command button on the worksheet and don't want to delete that. The button is "Button 55". Thanks, groundhog Sheets("Sheet1").Select ActiveSheet.Shapes.SelectAll ActiveSheet.Shapes("Button 55").Deselect Selection.Delete |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Change "Button 55" to "Button55"; controls can't have spaces in their names.
-- Trent Argante [DC.J(n/a)] "Jim Thomlinson" wrote: Give this a try... Sub RemovePictures() Dim shp As Shape For Each shp In ActiveSheet.Shapes If shp.Name < "Button 55" Then shp.Delete Next shp End Sub -- HTH... Jim Thomlinson "groundhog1" wrote: What's wrong with this code? It won't run. I am trying to select a .bmp image on my worksheet and delete it. I also have a command button on the worksheet and don't want to delete that. The button is "Button 55". Thanks, groundhog Sheets("Sheet1").Select ActiveSheet.Shapes.SelectAll ActiveSheet.Shapes("Button 55").Deselect Selection.Delete |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Buttons from the forms toolbar do have spaces in them by default when they
are added. Buttons from the control toolbox don't, but you can add them in if you wish... Named ranges can not have spaces in them, but objects such as shapes can. The code that groundhog first posted will crach if Button 55 does not exist, which is why I choose the route that I did. With the posted code, if button 55 does not exist then it will just delete all of the shapes... -- HTH... Jim Thomlinson "Trent Argante" wrote: Change "Button 55" to "Button55"; controls can't have spaces in their names. -- Trent Argante [DC.J(n/a)] "Jim Thomlinson" wrote: Give this a try... Sub RemovePictures() Dim shp As Shape For Each shp In ActiveSheet.Shapes If shp.Name < "Button 55" Then shp.Delete Next shp End Sub -- HTH... Jim Thomlinson "groundhog1" wrote: What's wrong with this code? It won't run. I am trying to select a .bmp image on my worksheet and delete it. I also have a command button on the worksheet and don't want to delete that. The button is "Button 55". Thanks, groundhog Sheets("Sheet1").Select ActiveSheet.Shapes.SelectAll ActiveSheet.Shapes("Button 55").Deselect Selection.Delete |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The one thing I neglected to mention (probably what you are describing) in
the properties for the command button from the control toolbox the "Name" can not have any spaces in it. In the drop down where you see the current cell address you can add the space. Why you ever would is a complete mystery but you can if that is what floats your boat. -- HTH... Jim Thomlinson "Jim Thomlinson" wrote: Buttons from the forms toolbar do have spaces in them by default when they are added. Buttons from the control toolbox don't, but you can add them in if you wish... Named ranges can not have spaces in them, but objects such as shapes can. The code that groundhog first posted will crach if Button 55 does not exist, which is why I choose the route that I did. With the posted code, if button 55 does not exist then it will just delete all of the shapes... -- HTH... Jim Thomlinson "Trent Argante" wrote: Change "Button 55" to "Button55"; controls can't have spaces in their names. -- Trent Argante [DC.J(n/a)] "Jim Thomlinson" wrote: Give this a try... Sub RemovePictures() Dim shp As Shape For Each shp In ActiveSheet.Shapes If shp.Name < "Button 55" Then shp.Delete Next shp End Sub -- HTH... Jim Thomlinson "groundhog1" wrote: What's wrong with this code? It won't run. I am trying to select a .bmp image on my worksheet and delete it. I also have a command button on the worksheet and don't want to delete that. The button is "Button 55". Thanks, groundhog Sheets("Sheet1").Select ActiveSheet.Shapes.SelectAll ActiveSheet.Shapes("Button 55").Deselect Selection.Delete |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I modified your code to print the names of each shape and found out what
you're talking about, and if that's not cunfusing, I don't know what is! It seems like Excel treats shapes like ranges... The route you took is the cleanest. Thanks for the extended explanation - it helped me at least. -- Trent Argante [DC.J(n/a)] "Jim Thomlinson" wrote: The one thing I neglected to mention (probably what you are describing) in the properties for the command button from the control toolbox the "Name" can not have any spaces in it. In the drop down where you see the current cell address you can add the space. Why you ever would is a complete mystery but you can if that is what floats your boat. -- HTH... Jim Thomlinson "Jim Thomlinson" wrote: Buttons from the forms toolbar do have spaces in them by default when they are added. Buttons from the control toolbox don't, but you can add them in if you wish... Named ranges can not have spaces in them, but objects such as shapes can. The code that groundhog first posted will crach if Button 55 does not exist, which is why I choose the route that I did. With the posted code, if button 55 does not exist then it will just delete all of the shapes... -- HTH... Jim Thomlinson "Trent Argante" wrote: Change "Button 55" to "Button55"; controls can't have spaces in their names. -- Trent Argante [DC.J(n/a)] "Jim Thomlinson" wrote: Give this a try... Sub RemovePictures() Dim shp As Shape For Each shp In ActiveSheet.Shapes If shp.Name < "Button 55" Then shp.Delete Next shp End Sub -- HTH... Jim Thomlinson "groundhog1" wrote: What's wrong with this code? It won't run. I am trying to select a .bmp image on my worksheet and delete it. I also have a command button on the worksheet and don't want to delete that. The button is "Button 55". Thanks, groundhog Sheets("Sheet1").Select ActiveSheet.Shapes.SelectAll ActiveSheet.Shapes("Button 55").Deselect Selection.Delete |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks very much Jim,
that worked very well. groundhog |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks very much Jim,
that worked very well. groundhog |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selecting AND Deleting | Excel Discussion (Misc queries) | |||
Hyperlink to an image in other worksheet, displaying entire image. | Excel Worksheet Functions | |||
selecting and deleting a row based on a cell value | Excel Programming | |||
Selecting Text and deleting Page | Excel Programming | |||
Export the worksheet background image as an image file - possible? | Excel Programming |