Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JK JK is offline
external usenet poster
 
Posts: 78
Default Why can't I delete this shape now?

I have been using the following code to delete a shape for the the past
several years.

Option Explicit

Sub ClearPicture()

'DELETE IMAGE MKTPKG

Dim X As Shape

On Error Resume Next

Set X = Sheets("MktPkg").Shapes(1)

If Err = 0 Then

X.Delete

End If

End Sub



In fact, it still works on one version of my software, but on the other it
mysteriously stopped working. The shape gets pasted to the worksheet just
fine, but now, for some reason, it won't delete. I've tried cleaning my code
with Rob Bovey's code cleaner, but it still doesn't execute. When I remove
the On Error Resume Next, the message says Application-defined or
application-defined error.



What happened? Even for all the changes I've been making to the program, I
never touched this.



Please help if you can. Thank you.



Jim Kobzeff


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Why can't I delete this shape now?

Hi Jim,

A protected worksheet could cause that error. Is that the problem ?


Regards,
Vic Eldridge


"JK" wrote:

I have been using the following code to delete a shape for the the past
several years.

Option Explicit

Sub ClearPicture()

'DELETE IMAGE MKTPKG

Dim X As Shape

On Error Resume Next

Set X = Sheets("MktPkg").Shapes(1)

If Err = 0 Then

X.Delete

End If

End Sub



In fact, it still works on one version of my software, but on the other it
mysteriously stopped working. The shape gets pasted to the worksheet just
fine, but now, for some reason, it won't delete. I've tried cleaning my code
with Rob Bovey's code cleaner, but it still doesn't execute. When I remove
the On Error Resume Next, the message says Application-defined or
application-defined error.



What happened? Even for all the changes I've been making to the program, I
never touched this.



Please help if you can. Thank you.



Jim Kobzeff



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Why can't I delete this shape now?

you may have the sheet protected

the code is tidied up...

Sub ClearPicture()

With ActiveSheet.Shapes
If .Count 0 Then
.Item(1).Delete
End If
End With

End Sub

"JK" wrote:

I have been using the following code to delete a shape for the the past
several years.

Option Explicit

Sub ClearPicture()

'DELETE IMAGE MKTPKG

Dim X As Shape

On Error Resume Next

Set X = Sheets("MktPkg").Shapes(1)

If Err = 0 Then

X.Delete

End If

End Sub



In fact, it still works on one version of my software, but on the other it
mysteriously stopped working. The shape gets pasted to the worksheet just
fine, but now, for some reason, it won't delete. I've tried cleaning my code
with Rob Bovey's code cleaner, but it still doesn't execute. When I remove
the On Error Resume Next, the message says Application-defined or
application-defined error.



What happened? Even for all the changes I've been making to the program, I
never touched this.



Please help if you can. Thank you.



Jim Kobzeff



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Why can't I delete this shape now?

maybe a protected sheet, also using the err object as a control is possibly
a problem. On Error Resume Next clears the error stack, so if your If err
statement is dealt with differently. What versions of Excel are you testing
in?

--
Cheers
Nigel



"JK" wrote in message news:Le_De.11686$JJ.9892@trnddc09...
I have been using the following code to delete a shape for the the past
several years.

Option Explicit

Sub ClearPicture()

'DELETE IMAGE MKTPKG

Dim X As Shape

On Error Resume Next

Set X = Sheets("MktPkg").Shapes(1)

If Err = 0 Then

X.Delete

End If

End Sub



In fact, it still works on one version of my software, but on the other it
mysteriously stopped working. The shape gets pasted to the worksheet just
fine, but now, for some reason, it won't delete. I've tried cleaning my

code
with Rob Bovey's code cleaner, but it still doesn't execute. When I remove
the On Error Resume Next, the message says Application-defined or
application-defined error.



What happened? Even for all the changes I've been making to the program, I
never touched this.



Please help if you can. Thank you.



Jim Kobzeff




  #5   Report Post  
Posted to microsoft.public.excel.programming
JK JK is offline
external usenet poster
 
Posts: 78
Default Why can't I delete this shape now?

Thank you group. A combination of adding Worksheet.Unprotect and Patrick's
tidied up procedure, got it working.

"JK" wrote in message news:Le_De.11686$JJ.9892@trnddc09...
I have been using the following code to delete a shape for the the past
several years.

Option Explicit

Sub ClearPicture()

'DELETE IMAGE MKTPKG

Dim X As Shape

On Error Resume Next

Set X = Sheets("MktPkg").Shapes(1)

If Err = 0 Then

X.Delete

End If

End Sub



In fact, it still works on one version of my software, but on the other it
mysteriously stopped working. The shape gets pasted to the worksheet just
fine, but now, for some reason, it won't delete. I've tried cleaning my
code with Rob Bovey's code cleaner, but it still doesn't execute. When I
remove the On Error Resume Next, the message says Application-defined or
application-defined error.



What happened? Even for all the changes I've been making to the program, I
never touched this.



Please help if you can. Thank you.



Jim Kobzeff




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
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM
Deleting a shape and the cell contents the shape is in. Dave Peterson[_3_] Excel Programming 1 October 9th 03 03:36 PM
Deleting a shape and the cell contents the shape is in. Tom Ogilvy Excel Programming 0 October 9th 03 03:43 AM
Shape connectors Davwe Excel Programming 3 October 4th 03 10:51 AM


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