Protection lost on Open

G

GCF

It is my intention to disable users from selecting any cells on
worksheet that I have just created in a workbook using EXCEL 2002. New
to VB, I rely greatly on recording macros then cut/paste. In this case
I did a Ctl+A to select all cells, then Format>Cells - Protection,
checked Locked & Hidden and then "OK". Then I went to
Tools>Protection>Protect Sheet. With the exception of "Protect
worksheet and contents of locked cells" all boxes were unchecked when I
hit "OK". The following code was generated:

Cells.Select
Range("C3").Activate
Selection.Locked = True
Selection.FormulaHidden = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Cells.Select
Range("C3").Activate

If I then unprotect the worksheet and run the macro, as intended, all
cells are not selectable.

The problem I have is that if the workbook is closed and reopened,
cells are once again selectable and can be copied. Is there a
programmable solution for retaining the protection as implemented?

Thanks,
GCF
 
P

Patrick Molloy

I suggest that you do it the othjer way around.
Protect the cells & worksheet then save the workbook.
That way, protection is ON when opened. Use the VBA code
to remove the proetection - use a password. Remember
though that you must keep a note of the password !!!

Patrick Molloy
Microsoft Excel MVP
 
D

Dick Johnson

Hi

The problem GCF is having is similar to mine

Marcos in Templates "Dick Johnson"
<[email protected]> Dec 21 2003 9:30PM

When I open a template form as a new doc the protection is
lost. I save the form template with the protection on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top