Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Selecting image on worksheet and deleting..

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Selecting image on worksheet and deleting..

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Selecting image on worksheet and deleting..

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Selecting image on worksheet and deleting..

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Selecting image on worksheet and deleting..

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Selecting image on worksheet and deleting..

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Selecting image on worksheet and deleting..

Thanks very much Jim,
that worked very well.
groundhog

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Selecting image on worksheet and deleting..

Thanks very much Jim,
that worked very well.
groundhog

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
Selecting AND Deleting bodhisatvaofboogie Excel Discussion (Misc queries) 11 May 24th 06 01:18 PM
Hyperlink to an image in other worksheet, displaying entire image. twilliams Excel Worksheet Functions 0 February 7th 06 10:02 PM
selecting and deleting a row based on a cell value JJ Excel Programming 4 December 1st 04 05:59 PM
Selecting Text and deleting Page andycharger[_30_] Excel Programming 1 May 18th 04 11:04 AM
Export the worksheet background image as an image file - possible? DataFreakFromUtah Excel Programming 2 April 10th 04 04:49 PM


All times are GMT +1. The time now is 07:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"