close

Hello, I want to make sure that my workbook doesnt close until every
single sheet is protected if any worksheet is left unprotected then the
user must protect it before being able to close the workbook, How can i
do this...possibly showing an error message too...

Thanks a lot
From John--
Neo1
------------------------------------------------------------------------
Neo1's Profile: www.excelforum.com/member.php...oamp;userid=30329
View this thread: www.excelforum.com/showthread...hreadid=531466If you name a macro beforeClose() this run before the workbook closes.
You can then put the code in here to make the sheets protected.

Thanks
Paul

quot;Neo1quot; wrote:

gt;
gt; Hello, I want to make sure that my workbook doesnt close until every
gt; single sheet is protected if any worksheet is left unprotected then the
gt; user must protect it before being able to close the workbook, How can i
gt; do this...possibly showing an error message too...
gt;
gt; Thanks a lot
gt; From John
gt;
gt;
gt; --
gt; Neo1
gt; ------------------------------------------------------------------------
gt; Neo1's Profile: www.excelforum.com/member.php...oamp;userid=30329
gt; View this thread: www.excelforum.com/showthread...hreadid=531466
gt;
gt;


I dont understand, can you explain it to me step to step please

Thanks a lot
From John--
Neo1
------------------------------------------------------------------------
Neo1's Profile: www.excelforum.com/member.php...oamp;userid=30329
View this thread: www.excelforum.com/showthread...hreadid=531466John
Put the code below in the Thisworkbook not in a normal module in the VBA
editor.
If you want I can email you the file
Thanks
Paul

Private Sub Workbook_BeforeClose(Cancel As Boolean)
sh = Worksheets.Count

For n = 1 To sh
Sheets(n).Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Next n

End Sub

quot;Neo1quot; wrote:

gt;
gt; I dont understand, can you explain it to me step to step please
gt;
gt; Thanks a lot
gt; From John
gt;
gt;
gt; --
gt; Neo1
gt; ------------------------------------------------------------------------
gt; Neo1's Profile: www.excelforum.com/member.php...oamp;userid=30329
gt; View this thread: www.excelforum.com/showthread...hreadid=531466
gt;
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()