Excel97 - Worksheet Protection Question

  • Thread starter Thread starter Russell Plummer
  • Start date Start date
R

Russell Plummer

Trying to create a form for users which is locked until they press a button
to enter values. I'm having a problem getting the worksheet to unlock so I
can set a range for data entry then lock again. Code fragment is:

Worksheets(WkShtName).Unprotect
Worksheets(WkShtName).Range("B3").Locked = False
Worksheets(WkShtName).Protect

When I try to test this I get an "Error 1004 Unprotect Method of Worksheet
Class failed" on the first line if the Worksheet is locked, and "unable to
set the Locked property of the Range class" if the sheet is unlocked when I
invoke the code.

Stranger still, the code is invoked from a button handler - if I use the
button I get error above, but if I run the code under the VBA Editor, then
it runs OK IF the worksheet is unprotected..hmmm

Can anyone point me in the right direction to make this work please

Thanks

Russell

(e-mail address removed)
 
This is a bug in 97

You can put this line in your code(first line)
ActiveCell.Activate

Or Set the SetFocusOnClick property of the button to false
in the properties of the button
 
Thanks Ron,

I thought it was me!

Russell


Ron de Bruin said:
This is a bug in 97

You can put this line in your code(first line)
ActiveCell.Activate

Or Set the SetFocusOnClick property of the button to false
in the properties of the button
 
Back
Top