PC Review


Reply
Thread Tools Rate Thread

Deleting a command button...

 
 
John Keith
Guest
Posts: n/a
 
      28th Apr 2008
THIS MONTH has a command button named "btnProcessData"
After the copy, the new sheet that has been renamed to the text string
stored in sWksName still has the button named exactly the same (verified with
a For Each loop displaying the names of all shapes on the new sheet)
Why does this code cause an error?

With ThisWorkbook
.Sheets("THIS MONTH").Copy After:=.Sheets(.Sheets.Count)
.Sheets("THIS MONTH (2)").Name = sWksName
.Sheets(sWksName).Shapes("btnProcessData").Delete
End With

The ".delete" is getting a runtime error 1004 application defined or object
defined error.

--
Regards,
John
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      28th Apr 2008
Check your button name in the new sheet. I'm not sure it copies the name over.

"John Keith" wrote:

> THIS MONTH has a command button named "btnProcessData"
> After the copy, the new sheet that has been renamed to the text string
> stored in sWksName still has the button named exactly the same (verified with
> a For Each loop displaying the names of all shapes on the new sheet)
> Why does this code cause an error?
>
> With ThisWorkbook
> .Sheets("THIS MONTH").Copy After:=.Sheets(.Sheets.Count)
> .Sheets("THIS MONTH (2)").Name = sWksName
> .Sheets(sWksName).Shapes("btnProcessData").Delete
> End With
>
> The ".delete" is getting a runtime error 1004 application defined or object
> defined error.
>
> --
> Regards,
> John

 
Reply With Quote
 
John Keith
Guest
Posts: n/a
 
      29th Apr 2008
It is named the same. A for each sh in activesheet.shapes... showing all
shape names in a msgbox verified that the name was the same.

I discovered the problem was that my sheet was protected. There really
should be a better error message to report when you are trying to change a
protected sheet. Maybe since this is a shape as opposed to a value or
formula MS didnt extend the errors to fully cover shapes.

--
Regards,
John


"JLGWhiz" wrote:

> Check your button name in the new sheet. I'm not sure it copies the name over.
>
> "John Keith" wrote:
>
> > THIS MONTH has a command button named "btnProcessData"
> > After the copy, the new sheet that has been renamed to the text string
> > stored in sWksName still has the button named exactly the same (verified with
> > a For Each loop displaying the names of all shapes on the new sheet)
> > Why does this code cause an error?
> >
> > With ThisWorkbook
> > .Sheets("THIS MONTH").Copy After:=.Sheets(.Sheets.Count)
> > .Sheets("THIS MONTH (2)").Name = sWksName
> > .Sheets(sWksName).Shapes("btnProcessData").Delete
> > End With
> >
> > The ".delete" is getting a runtime error 1004 application defined or object
> > defined error.
> >
> > --
> > Regards,
> > John

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      29th Apr 2008
Some of the error messages are lacking in specificity and you have to do a
lot of trouble shooting to tie down the problem. I was not sure about the
name transfer. I know it copies any associated code over for each control,
guess I should have assumed the name would be copied over also. Glad you
found the problem and thanks for posting back. Helps me learn also.

"John Keith" wrote:

> It is named the same. A for each sh in activesheet.shapes... showing all
> shape names in a msgbox verified that the name was the same.
>
> I discovered the problem was that my sheet was protected. There really
> should be a better error message to report when you are trying to change a
> protected sheet. Maybe since this is a shape as opposed to a value or
> formula MS didnt extend the errors to fully cover shapes.
>
> --
> Regards,
> John
>
>
> "JLGWhiz" wrote:
>
> > Check your button name in the new sheet. I'm not sure it copies the name over.
> >
> > "John Keith" wrote:
> >
> > > THIS MONTH has a command button named "btnProcessData"
> > > After the copy, the new sheet that has been renamed to the text string
> > > stored in sWksName still has the button named exactly the same (verified with
> > > a For Each loop displaying the names of all shapes on the new sheet)
> > > Why does this code cause an error?
> > >
> > > With ThisWorkbook
> > > .Sheets("THIS MONTH").Copy After:=.Sheets(.Sheets.Count)
> > > .Sheets("THIS MONTH (2)").Name = sWksName
> > > .Sheets(sWksName).Shapes("btnProcessData").Delete
> > > End With
> > >
> > > The ".delete" is getting a runtime error 1004 application defined or object
> > > defined error.
> > >
> > > --
> > > Regards,
> > > John

 
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
Deleting a Command Button Tdahlman Microsoft Excel Misc 3 20th Dec 2007 08:34 PM
Deleting a Command Button from my Spreadsheet =?Utf-8?B?RERyb3dl?= Microsoft Excel Misc 2 7th Nov 2006 01:49 PM
Deleting Command Button =?Utf-8?B?SmFtZXMgVy4=?= Microsoft Excel Programming 1 11th Jan 2005 08:38 PM
Re: Deleting a Command Button fredg Microsoft Access Form Coding 0 29th Jul 2004 10:13 PM
Deleting some cells in a row using command button and offset Marvin Microsoft Excel Programming 3 6th Apr 2004 02:36 AM


Features
 

Advertising
 

Newsgroups
 


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