PC Review


Reply
Thread Tools Rate Thread

Delete shapes, not buttons

 
 
=?Utf-8?B?ZXdhbjcyNzk=?=
Guest
Posts: n/a
 
      17th Jul 2007
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      17th Jul 2007
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" <(E-Mail Removed)> wrote in message
news:981EC62A-F450-49B3-8D1E-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      17th Jul 2007
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

 
Reply With Quote
 
=?Utf-8?B?ZXdhbjcyNzk=?=
Guest
Posts: n/a
 
      17th Jul 2007
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" <(E-Mail Removed)> wrote in message
> news:981EC62A-F450-49B3-8D1E-(E-Mail Removed)...
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide shapes (buttons) before printing Ken Loomis Microsoft Excel Programming 7 2nd Mar 2011 02:19 AM
How do I protect shapes and buttons in a sheet? yajiv.vijay@gmail.com Microsoft Excel Programming 1 20th Feb 2008 09:49 AM
How do you delete all buttons in a worksheet, but not all shapes =?Utf-8?B?U3RldmVD?= Microsoft Excel Programming 2 16th Feb 2007 04:04 AM
Formatting buttons & drawing shapes. nomadscot Microsoft Excel Discussion 4 15th Jul 2006 04:52 PM
Delete Shapes using VBA =?Utf-8?B?Tmlra2k=?= Microsoft Powerpoint 4 27th Jan 2006 05:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:15 PM.