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

charlie79

Board Regular
Joined
Feb 27, 2002
Messages
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
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi Charlie


It could be due to the method used to run the code. If using a ActiveX CommandButton set it's "TakeFocusOnClick" Property to False.
 
Upvote 0
A little side note, I started with an empty xl97 workbook, added a commandbutton and put:

commandbutton1.takefocusonclick = 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.

????
 
Upvote 0
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.
 
Upvote 0
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.

???
 
Upvote 0
Charlie, I am not suggesting to not 'Protect/Unprotect' at 'Run-Time', I mean the "TakeFocusOnClick" Property of the Control running the code.
 
Upvote 0
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!
:wink:
 
Upvote 0
Oops!
Guess what. A combobox does not have the property, TakeFocusOnClick. 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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,176
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top