Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default Error unprotecting worksheet

I have encountered a run time error 1004: unprotect method of worksheet class
failed.

I have written an "unprotect the worksheet" macro that includes:
ActiveSheet.Unprotect password:="something"

When I run this macro in Excel 2000 indpenedently and referenced within
other macros it works fine. However, when I run this macro on other machines
running Excel 97, the error occurs. Any and all help is appreciated.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Error unprotecting worksheet

Try setting the TakeFocusOnClick property of the buttons (if any) to False.
That's usually the culprit

--
Regards

Juan Pablo González

"Chad" wrote in message
...
I have encountered a run time error 1004: unprotect method of worksheet

class
failed.

I have written an "unprotect the worksheet" macro that includes:
ActiveSheet.Unprotect password:="something"

When I run this macro in Excel 2000 indpenedently and referenced within
other macros it works fine. However, when I run this macro on other

machines
running Excel 97, the error occurs. Any and all help is appreciated.

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Error unprotecting worksheet

You sure you're on the correct sheet?

msgbox activesheet.name



Chad wrote:

I have encountered a run time error 1004: unprotect method of worksheet class
failed.

I have written an "unprotect the worksheet" macro that includes:
ActiveSheet.Unprotect password:="something"

When I run this macro in Excel 2000 indpenedently and referenced within
other macros it works fine. However, when I run this macro on other machines
running Excel 97, the error occurs. Any and all help is appreciated.

Thanks in advance.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default Error unprotecting worksheet

Yes, I'm on the correct sheet. Everything works correctly in Excel 2000, its
on a different computer with the Excel 97 version that the error occurs.
Does Excel 97 have a problem recognizing this sheet protection code? I know
you can manually do it in both versions the same way via
Tools\Protection\Protect Sheet, but perhaps the code is different. Any
thoughts. Many thanks.

"Dave Peterson" wrote:

You sure you're on the correct sheet?

msgbox activesheet.name



Chad wrote:

I have encountered a run time error 1004: unprotect method of worksheet class
failed.

I have written an "unprotect the worksheet" macro that includes:
ActiveSheet.Unprotect password:="something"

When I run this macro in Excel 2000 indpenedently and referenced within
other macros it works fine. However, when I run this macro on other machines
running Excel 97, the error occurs. Any and all help is appreciated.

Thanks in advance.


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Error unprotecting worksheet

Mhm... not sure what might be happening. What if you refer to the sheet
directly ?

Sheets("YourSheet").Unprotect "thepassword"

--
Regards

Juan Pablo González

"Chad" wrote in message
...
Thanks, but that's not it. I've tried that. I've also tried selecting a
cell range to "take the focus off" of the button manually. The strangest
thing about it, is that if I run the macro by itself it works. However,

when
I run the macro inside of another macro it errors. Any additional

thoughts?

"Juan Pablo González" wrote:

Try setting the TakeFocusOnClick property of the buttons (if any) to

False.
That's usually the culprit

--
Regards

Juan Pablo González

"Chad" wrote in message
...
I have encountered a run time error 1004: unprotect method of

worksheet
class
failed.

I have written an "unprotect the worksheet" macro that includes:
ActiveSheet.Unprotect password:="something"

When I run this macro in Excel 2000 indpenedently and referenced

within
other macros it works fine. However, when I run this macro on other

machines
running Excel 97, the error occurs. Any and all help is appreciated.

Thanks in advance.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default Error unprotecting worksheet

I worked through the error. Apparently, in Excel 97 it is necessary to
select a range before you are able to protect/unprotect the sheet in addition
to the takefocusonclick=false code. Thanks to everyone for all of your help.

"Dave Peterson" wrote:

You sure you're on the correct sheet?

msgbox activesheet.name



Chad wrote:

I have encountered a run time error 1004: unprotect method of worksheet class
failed.

I have written an "unprotect the worksheet" macro that includes:
ActiveSheet.Unprotect password:="something"

When I run this macro in Excel 2000 indpenedently and referenced within
other macros it works fine. However, when I run this macro on other machines
running Excel 97, the error occurs. Any and all help is appreciated.

Thanks in advance.


--

Dave Peterson

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
Unprotecting a worksheet Jessica Excel Worksheet Functions 8 August 21st 08 06:43 PM
Unprotecting a Worksheet Anney Excel Worksheet Functions 7 August 4th 07 01:14 PM
unprotecting a worksheet Randy123 Excel Discussion (Misc queries) 1 August 8th 05 06:11 PM
Help with unprotecting worksheet in Excel 97 Steve Mikula Excel Programming 1 November 3rd 03 08:02 PM
Unprotecting worksheet in a macro. Mark F. Excel Programming 1 July 17th 03 08:38 PM


All times are GMT +1. The time now is 12:19 PM.

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"