+ Reply to Thread
Results 1 to 7 of 7

Error unprotecting worksheet

  1. #1
    Chad
    Guest

    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. #2
    Juan Pablo González
    Guest

    Re: 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" <Chad@discussions.microsoft.com> wrote in message
    news:7713388D-E183-4180-ACC2-D6D9A67989FD@microsoft.com...
    > 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. #3
    Chad
    Guest

    Re: Error unprotecting worksheet

    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" <Chad@discussions.microsoft.com> wrote in message
    > news:7713388D-E183-4180-ACC2-D6D9A67989FD@microsoft.com...
    > > 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.

    >
    >
    >


  4. #4
    Dave Peterson
    Guest

    Re: 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

  5. #5
    Chad
    Guest

    Re: 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
    >


  6. #6
    Juan Pablo Gonz&amp;aacute;lez
    Guest

    Re: 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" <Chad@discussions.microsoft.com> wrote in message
    news:CE2E2790-46BF-4F9A-960D-934E7F56A878@microsoft.com...
    > 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" <Chad@discussions.microsoft.com> wrote in message
    > > news:7713388D-E183-4180-ACC2-D6D9A67989FD@microsoft.com...
    > > > 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.

    > >
    > >
    > >




  7. #7
    Chad
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1