+ Reply to Thread
Results 1 to 4 of 4

Protecting Workbook!..

  1. #1
    Registered User
    Join Date
    01-10-2006
    Posts
    67

    Protecting Workbook!..

    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

  2. #2

    RE: Protecting Workbook!..

    If 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

    "Neo1" wrote:

    >
    > 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: http://www.excelforum.com/member.php...o&userid=30329
    > View this thread: http://www.excelforum.com/showthread...hreadid=531466
    >
    >


  3. #3
    Registered User
    Join Date
    01-10-2006
    Posts
    67
    I dont understand, can you explain it to me step to step please

    Thanks a lot
    From John

  4. #4

    Re: Protecting Workbook!..

    John
    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

    "Neo1" wrote:

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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1