PDA

View Full Version : Solved: Protect Sheet & Workbook



vzachin
11-12-2008, 07:20 PM
hi,

i unprotect the workbook/sheet when the code is running and when the code is finished, i protect the workbook/sheet.

i find that if i interrupt the code using the esc key, the sheet/workbook is no longer protected.
is there a way to prevent this, so that when the code is interuppted, the workbook & sheet is protected?
then if the code is resumed(continued), unprotect the workbook/sheet until it finishes?


thanks
zach

GTO
11-12-2008, 08:53 PM
Hi Zach,

Try this for an easy fix; if to no avail, maybe post code and/or wb example.

Anyways - for the easy try, replace your unprotect statement with:

Sheet1.Protect Password:="WhateverYourPasswordIs", DrawingObjects:=True, _
Contents:=True, Scenarios:=True, UserInterfaceOnly:=True

The fourth arg, "UserInterfaceOnly" allows programmatic chnages to occur, while keeping the user's fidgety fingers from goobering up your workbook.

Since the sheet is never unprotected, if the code goes fatal, the sheet is still protected.:*)

Hope this helps,

Mark

vzachin
11-13-2008, 04:49 AM
hi mark

very nice!

i was reading about UserInterfaceOnly but didn't quite understand how it works.


thanks again
zach

vzachin
11-13-2008, 04:59 AM
hi mark,
one last question.
how do i protect the workbook?

thanks
zach

vzachin
11-13-2008, 08:22 AM
mark
please disregard prev question.

thanks
zach