Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto protect on opening (excel xp)

    hello guys,

    can you guys give an example how to protect all sheets during the auto_open procedure ?

    something like

    sub auto_open()
    ????????
    ????????

    end sub

    i want to protect all my sheets everytime i open my file..thanks..

  2. #2
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Auto protect on opening (excel xp)

    Do you want to open a readonly version of the file?
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Auto protect on opening (excel xp)

    Add this to the thisworkbook object

    <pre>Option Explicit
    Private Sub Workbook_Open()
    Dim sht
    For Each sht In Sheets
    sht.Protect
    Next
    End Sub</pre>


    Steve

  4. #4
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto protect on opening (excel xp)

    thanks steve...

    how to add the password..let say "abc"

    thanks

  5. #5
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto protect on opening (excel xp)

    nope catherine..

    i just want to protect all my sheets everytime i open my file. thanks

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Auto protect on opening (excel xp)

    <P ID="edit" class=small>(Edited by sdckapr on 10-Jun-04 14:43. added PS)</P>Use the line:
    <pre>sht.Protect "abc"</pre>


    Instead of the one listed

    Steve
    PS if any of the sheets already have passwords, you will not get an error, but the sheets will be still have the old password, they will not be protected with the new password.

  7. #7
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Kuala Lumpur , MALAYSIA
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto protect on opening (excel xp)

    thanks steve..it works. regards

Posting Permissions

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