Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Sheet1.Unprotect does not work in xl 97? (Sorry, I still nee

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    97
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I created an excel app in xl2k. I used sheet protection throughout my vba code, without problems. Then going to xl 97 I find that the unprotect and protect method of sheets does not work. I am getting a Method 'Protect' of object '_Worksheet' failed runtime error.

    Sheet1.Protect or Sheet1.Unprotect

    ?????

    [ This Message was edited by: charlie79 on 2002-04-09 06:21 ]

    [ This Message was edited by: charlie79 on 2002-04-09 07:39 ]

  2. #2
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Charlie


    It could be due to the method used to run the code. If using a ActiveX CommandButton set it's "TakeFocus*******" Property to False.





  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    97
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Just tried that Dave, thanks for the suggestion but no go. Any other ideas?

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Posts
    97
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    A little side note, I started with an empty xl97 workbook, added a commandbutton and put:

    commandbutton1.takefocus******* = false
    sheet1.protect

    in the commandbutton1_click event and that produces same results. So I can assume this isn't an issue with creating the original workbook in xl2k.

    ????

  5. #5
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Charlie

    It would be worth setting this Property at 'Design-time' rather than 'Run-time'

    I am pretty certain there are no real issues with using a Sheets CodeName in 97 over 2000.



  6. #6
    Board Regular
    Join Date
    Feb 2002
    Posts
    97
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Here's the problem with that however Dave. My app is going to be used by sensitive users. By that I mean, somewhat illeterate as far as Excel goes. I do need the sheet protected, however, that sheet is being refreshed every 5 secs (I'm using an Add-In for another application that goes to a server to retrieve current values and my code then places those current values into cells). That said, on every refresh, I must unprotect first, then protect when done. Also, I have a comboboox that will change values in cells through the combobox's change event. The thing is, I know doing it at run-time works, in xl2k.

    ???

  7. #7
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Charlie, I am not suggesting to not 'Protect/Unprotect' at 'Run-Time', I mean the "TakeFocus*******" Property of the Control running the code.




  8. #8
    Board Regular
    Join Date
    Feb 2002
    Posts
    97
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sorry Dave, looks like that is going to work! Thanks a million. Do you have an explanation of why I didn't have to set that property for xl2k?

    Thanks again!

  9. #9
    Board Regular
    Join Date
    Feb 2002
    Posts
    97
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Oops!
    Guess what. A combobox does not have the property, TakeFocus*******. That is the main concern, when the user change the combobox, the sheet needs to be unprotected, update values in the cells, and then protected.

  10. #10
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Charlie

    Not too sure why, but it's a case of the fix of a problem in 97 causing problems of its own in 2000.





Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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