![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 97
|
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 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
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 |
|
Board Regular
Join Date: Feb 2002
Posts: 97
|
Just tried that Dave, thanks for the suggestion but no go. Any other ideas?
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Posts: 97
|
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 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
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 |
|
Board Regular
Join Date: Feb 2002
Posts: 97
|
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 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Charlie, I am not suggesting to not 'Protect/Unprotect' at 'Run-Time', I mean the "TakeFocus*******" Property of the Control running the code.
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Feb 2002
Posts: 97
|
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 |
|
Board Regular
Join Date: Feb 2002
Posts: 97
|
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 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
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. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|