Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Delete shapes, not buttons

Hi all,

I have embedded two buttons from the control toolbox onto my spreadsheet and
assigned macros to them. One counts and lists the number and serial of
photos, the other removes the hyperlinks within them. I would like to write
code to remove the photos, but leave the buttons. How do I do this please?
This is what I have so far (which deletes everything!!):

Sub RemovePhotos()

Dim mySh As shape

For Each mySh In ActiveSheet.Shapes
If Not mySh.Name = "Count_and_List_Photos" Or mySh.Name =
"RemoveHyperlinks" Then
mySh.Delete
Else
'do nothing
End If

Next mySh

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Delete shapes, not buttons

Sub RemovePhotos()
Dim mySh As Shape

For Each mySh In ActiveSheet.Shapes
If mySh.Type < msoOLEControlObject Then
If Not mySh.Name = "Count_and_List_Photos" Or mySh.Name =
"RemoveHyperlinks" Then
mySh.Delete
Else
'do nothing
End If
End If
Next mySh

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"ewan7279" wrote in message
...
Hi all,

I have embedded two buttons from the control toolbox onto my spreadsheet
and
assigned macros to them. One counts and lists the number and serial of
photos, the other removes the hyperlinks within them. I would like to
write
code to remove the photos, but leave the buttons. How do I do this
please?
This is what I have so far (which deletes everything!!):

Sub RemovePhotos()

Dim mySh As shape

For Each mySh In ActiveSheet.Shapes
If Not mySh.Name = "Count_and_List_Photos" Or mySh.Name =
"RemoveHyperlinks" Then
mySh.Delete
Else
'do nothing
End If

Next mySh

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Delete shapes, not buttons

Your logic is wrong. the not operator takes presedence over the and. You
really had:
(Not A) or B
You could have done
(Not A) and (Not B)
Applying DeMorgans
Not (A or B)

Sub RemovePhotos()

Dim mySh As shape

For Each mySh In ActiveSheet.Shapes
If (mySh.Name < "Count_and_List_Photos") and (mySh.Name =
"RemoveHyperlinks") Then
mySh.Delete
Else
'do nothing
End If

Next mySh

End Sub


"ewan7279" wrote:

Hi all,

I have embedded two buttons from the control toolbox onto my spreadsheet and
assigned macros to them. One counts and lists the number and serial of
photos, the other removes the hyperlinks within them. I would like to write
code to remove the photos, but leave the buttons. How do I do this please?
This is what I have so far (which deletes everything!!):

Sub RemovePhotos()

Dim mySh As shape

For Each mySh In ActiveSheet.Shapes
If Not mySh.Name = "Count_and_List_Photos" Or mySh.Name =
"RemoveHyperlinks" Then
mySh.Delete
Else
'do nothing
End If

Next mySh

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Delete shapes, not buttons

Thanks Bob - you're a star!!

I'll have to read up on msoOLEControlObject...

"Bob Phillips" wrote:

Sub RemovePhotos()
Dim mySh As Shape

For Each mySh In ActiveSheet.Shapes
If mySh.Type < msoOLEControlObject Then
If Not mySh.Name = "Count_and_List_Photos" Or mySh.Name =
"RemoveHyperlinks" Then
mySh.Delete
Else
'do nothing
End If
End If
Next mySh

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"ewan7279" wrote in message
...
Hi all,

I have embedded two buttons from the control toolbox onto my spreadsheet
and
assigned macros to them. One counts and lists the number and serial of
photos, the other removes the hyperlinks within them. I would like to
write
code to remove the photos, but leave the buttons. How do I do this
please?
This is what I have so far (which deletes everything!!):

Sub RemovePhotos()

Dim mySh As shape

For Each mySh In ActiveSheet.Shapes
If Not mySh.Name = "Count_and_List_Photos" Or mySh.Name =
"RemoveHyperlinks" Then
mySh.Delete
Else
'do nothing
End If

Next mySh

End Sub




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
Add and delete pictures and shapes jlclyde Excel Discussion (Misc queries) 2 October 22nd 08 02:54 PM
How do you delete all buttons in a worksheet, but not all shapes SteveC Excel Programming 2 February 16th 07 04:04 AM
HOW DO I DELETE SHAPES THAT ARE IN SPREADSHEETS? Chuck Excel Discussion (Misc queries) 2 February 19th 06 11:14 AM
Hide shapes (buttons) before printing Ken Loomis Excel Programming 6 October 6th 04 08:15 PM
Delete Shapes acces[_7_] Excel Programming 1 May 7th 04 06:51 PM


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