Excel VBA Protection/Unprotection


Posted by David Polen on March 06, 2000 2:35 PM

I'm trying to use VBA to unprotect a protected worksheet, make some changes, then reprotect it (mostly because I can't add/delete comments to ANY cells - even unlocked ones - when the worksheet is protected).

Unfortunately, invoking the Protect method for a Worksheet object seems always to produce the following error:

'Protect method of worksheet class failed.'

I get this error even in isolation when I create a new workbook, put a button on Sheet 1, and specify "ActiveSheet.Protect" as the only code in the
button's Click method.

Can anyone help?

Posted by David Polen on March 07, 2000 9:12 AM

Uhmm - BTW - this is for Excel 97.

Posted by Ivan Moala on March 08, 2000 1:08 AM

Hi david
have a look @ the online help for;
UserInterfaceOnly = Optional Variant. True to protect the user interface, but not macros. If this argument is omitted, protection applies both to macros and to the user interface.

Ivan



Posted by David Polen on March 09, 2000 9:28 AM

Alas, a red herring. I’ve already tried this...