+ Reply to Thread
Results 1 to 6 of 6

macro for Protecting a Sheet

Hybrid View

  1. #1
    cincode5
    Guest

    macro for Protecting a Sheet

    Hello everyone...

    Just wondering what the line of code would look like that protects a sheet
    via the press of a (macro) button. For reason undisclosed, I dont want users
    to go the Tools / Protection routine, but I can only get the macro to work
    without password protection. Here is what I am using:

    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

    but again this only works without a password.

    Any ideas?

    --
    Regards...

  2. #2
    Alan
    Guest

    Re: macro for Protecting a Sheet

    Try
    ActiveSheet.Protect ("Your_Password")
    Regards,
    Alan.
    "cincode5" <cincode5@discussions.microsoft.com> wrote in message
    news:97EF4E0C-08E8-443C-B5A5-19750F788C11@microsoft.com...
    > Hello everyone...
    >
    > Just wondering what the line of code would look like that protects a sheet
    > via the press of a (macro) button. For reason undisclosed, I dont want
    > users
    > to go the Tools / Protection routine, but I can only get the macro to work
    > without password protection. Here is what I am using:
    >
    > ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    >
    > but again this only works without a password.
    >
    > Any ideas?
    >
    > --
    > Regards...




  3. #3
    cincode5
    Guest

    Re: macro for Protecting a Sheet

    Hi Alan & thanks...

    This works great, although it wasn't exactly what I was looking to
    accomplish since this approach predefines the password (assuming I'm applying
    your suggestion correctly). Consequently however, it does solves another
    issue with this spreadsheet - namely admin security and control.

    These users arent sophistated enough to know how to compromise an xls
    password, but I've incorporated adminstrator control regardless to address
    multi users (families members) who have editing privlidges via 'Allow Users
    to Edit Ranges'. I'm giving this spreadsheet to acquentences so its not a
    Corp thing, but this approach will require I give those less knowledgable
    with VB instructions on how to modify the password within the macro. Not a
    problem though.

    Thanks again for the tip. Much appreciated.
    --
    Regards...


    "Alan" wrote:

    > Try
    > ActiveSheet.Protect ("Your_Password")
    > Regards,
    > Alan.
    > "cincode5" <cincode5@discussions.microsoft.com> wrote in message
    > news:97EF4E0C-08E8-443C-B5A5-19750F788C11@microsoft.com...
    > > Hello everyone...
    > >
    > > Just wondering what the line of code would look like that protects a sheet
    > > via the press of a (macro) button. For reason undisclosed, I dont want
    > > users
    > > to go the Tools / Protection routine, but I can only get the macro to work
    > > without password protection. Here is what I am using:
    > >
    > > ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    > >
    > > but again this only works without a password.
    > >
    > > Any ideas?
    > >
    > > --
    > > Regards...

    >
    >
    >


  4. #4
    Paul B
    Guest

    Re: macro for Protecting a Sheet

    cincode5, if you want the user to pick a password you could use something
    like this

    Sub protect()
    Dim pw As String
    pw = InputBox("Enter your password to protect the sheet ?")
    ActiveSheet.protect Password:=pw, DrawingObjects:=True, _
    Contents:=True, Scenarios:=True
    End Sub


    --
    Paul B
    Always backup your data before trying something new
    Please post any response to the newsgroups so others can benefit from it
    Feedback on answers is always appreciated!
    Using Excel 2002 & 2003

    "cincode5" <cincode5@discussions.microsoft.com> wrote in message
    news:5255F411-15EF-4CB6-9673-685F8B659C8D@microsoft.com...
    > Hi Alan & thanks...
    >
    > This works great, although it wasn't exactly what I was looking to
    > accomplish since this approach predefines the password (assuming I'm

    applying
    > your suggestion correctly). Consequently however, it does solves another
    > issue with this spreadsheet - namely admin security and control.
    >
    > These users arent sophistated enough to know how to compromise an xls
    > password, but I've incorporated adminstrator control regardless to address
    > multi users (families members) who have editing privlidges via 'Allow

    Users
    > to Edit Ranges'. I'm giving this spreadsheet to acquentences so its not a
    > Corp thing, but this approach will require I give those less knowledgable
    > with VB instructions on how to modify the password within the macro. Not

    a
    > problem though.
    >
    > Thanks again for the tip. Much appreciated.
    > --
    > Regards...
    >
    >
    > "Alan" wrote:
    >
    > > Try
    > > ActiveSheet.Protect ("Your_Password")
    > > Regards,
    > > Alan.
    > > "cincode5" <cincode5@discussions.microsoft.com> wrote in message
    > > news:97EF4E0C-08E8-443C-B5A5-19750F788C11@microsoft.com...
    > > > Hello everyone...
    > > >
    > > > Just wondering what the line of code would look like that protects a

    sheet
    > > > via the press of a (macro) button. For reason undisclosed, I dont

    want
    > > > users
    > > > to go the Tools / Protection routine, but I can only get the macro to

    work
    > > > without password protection. Here is what I am using:
    > > >
    > > > ActiveSheet.Protect DrawingObjects:=True, Contents:=True,

    Scenarios:=True
    > > >
    > > > but again this only works without a password.
    > > >
    > > > Any ideas?
    > > >
    > > > --
    > > > Regards...

    > >
    > >
    > >




  5. #5
    cincode5
    Guest

    Re: macro for Protecting a Sheet

    Paul...
    Even better... Thanks for the tip.

    I needed to have the individulal admin set the password without accessing VB
    code. This is what I was looking for.

    Thanks again Paul!
    --
    Regards...
    --
    Regards...


    "Paul B" wrote:

    > cincode5, if you want the user to pick a password you could use something
    > like this
    >
    > Sub protect()
    > Dim pw As String
    > pw = InputBox("Enter your password to protect the sheet ?")
    > ActiveSheet.protect Password:=pw, DrawingObjects:=True, _
    > Contents:=True, Scenarios:=True
    > End Sub
    >
    >
    > --
    > Paul B
    > Always backup your data before trying something new
    > Please post any response to the newsgroups so others can benefit from it
    > Feedback on answers is always appreciated!
    > Using Excel 2002 & 2003
    >
    > "cincode5" <cincode5@discussions.microsoft.com> wrote in message
    > news:5255F411-15EF-4CB6-9673-685F8B659C8D@microsoft.com...
    > > Hi Alan & thanks...
    > >
    > > This works great, although it wasn't exactly what I was looking to
    > > accomplish since this approach predefines the password (assuming I'm

    > applying
    > > your suggestion correctly). Consequently however, it does solves another
    > > issue with this spreadsheet - namely admin security and control.
    > >
    > > These users arent sophistated enough to know how to compromise an xls
    > > password, but I've incorporated adminstrator control regardless to address
    > > multi users (families members) who have editing privlidges via 'Allow

    > Users
    > > to Edit Ranges'. I'm giving this spreadsheet to acquentences so its not a
    > > Corp thing, but this approach will require I give those less knowledgable
    > > with VB instructions on how to modify the password within the macro. Not

    > a
    > > problem though.
    > >
    > > Thanks again for the tip. Much appreciated.
    > > --
    > > Regards...
    > >
    > >
    > > "Alan" wrote:
    > >
    > > > Try
    > > > ActiveSheet.Protect ("Your_Password")
    > > > Regards,
    > > > Alan.
    > > > "cincode5" <cincode5@discussions.microsoft.com> wrote in message
    > > > news:97EF4E0C-08E8-443C-B5A5-19750F788C11@microsoft.com...
    > > > > Hello everyone...
    > > > >
    > > > > Just wondering what the line of code would look like that protects a

    > sheet
    > > > > via the press of a (macro) button. For reason undisclosed, I dont

    > want
    > > > > users
    > > > > to go the Tools / Protection routine, but I can only get the macro to

    > work
    > > > > without password protection. Here is what I am using:
    > > > >
    > > > > ActiveSheet.Protect DrawingObjects:=True, Contents:=True,

    > Scenarios:=True
    > > > >
    > > > > but again this only works without a password.
    > > > >
    > > > > Any ideas?
    > > > >
    > > > > --
    > > > > Regards...
    > > >
    > > >
    > > >

    >
    >
    >


  6. #6
    Paul B
    Guest

    Re: macro for Protecting a Sheet

    Your Welcome

    --
    Paul B
    Always backup your data before trying something new
    Please post any response to the newsgroups so others can benefit from it
    Feedback on answers is always appreciated!
    Using Excel 2002 & 2003

    "cincode5" <cincode5@discussions.microsoft.com> wrote in message
    news:81814705-9F24-48BB-8DC9-818CA959BE24@microsoft.com...
    > Paul...
    > Even better... Thanks for the tip.
    >
    > I needed to have the individulal admin set the password without accessing

    VB
    > code. This is what I was looking for.
    >
    > Thanks again Paul!
    > --
    > Regards...
    > --
    > Regards...
    >
    >
    > "Paul B" wrote:
    >
    > > cincode5, if you want the user to pick a password you could use

    something
    > > like this
    > >
    > > Sub protect()
    > > Dim pw As String
    > > pw = InputBox("Enter your password to protect the sheet ?")
    > > ActiveSheet.protect Password:=pw, DrawingObjects:=True, _
    > > Contents:=True, Scenarios:=True
    > > End Sub
    > >
    > >
    > > --
    > > Paul B
    > > Always backup your data before trying something new
    > > Please post any response to the newsgroups so others can benefit from it
    > > Feedback on answers is always appreciated!
    > > Using Excel 2002 & 2003
    > >
    > > "cincode5" <cincode5@discussions.microsoft.com> wrote in message
    > > news:5255F411-15EF-4CB6-9673-685F8B659C8D@microsoft.com...
    > > > Hi Alan & thanks...
    > > >
    > > > This works great, although it wasn't exactly what I was looking to
    > > > accomplish since this approach predefines the password (assuming I'm

    > > applying
    > > > your suggestion correctly). Consequently however, it does solves

    another
    > > > issue with this spreadsheet - namely admin security and control.
    > > >
    > > > These users arent sophistated enough to know how to compromise an xls
    > > > password, but I've incorporated adminstrator control regardless to

    address
    > > > multi users (families members) who have editing privlidges via 'Allow

    > > Users
    > > > to Edit Ranges'. I'm giving this spreadsheet to acquentences so its

    not a
    > > > Corp thing, but this approach will require I give those less

    knowledgable
    > > > with VB instructions on how to modify the password within the macro.

    Not
    > > a
    > > > problem though.
    > > >
    > > > Thanks again for the tip. Much appreciated.
    > > > --
    > > > Regards...
    > > >
    > > >
    > > > "Alan" wrote:
    > > >
    > > > > Try
    > > > > ActiveSheet.Protect ("Your_Password")
    > > > > Regards,
    > > > > Alan.
    > > > > "cincode5" <cincode5@discussions.microsoft.com> wrote in message
    > > > > news:97EF4E0C-08E8-443C-B5A5-19750F788C11@microsoft.com...
    > > > > > Hello everyone...
    > > > > >
    > > > > > Just wondering what the line of code would look like that protects

    a
    > > sheet
    > > > > > via the press of a (macro) button. For reason undisclosed, I dont

    > > want
    > > > > > users
    > > > > > to go the Tools / Protection routine, but I can only get the macro

    to
    > > work
    > > > > > without password protection. Here is what I am using:
    > > > > >
    > > > > > ActiveSheet.Protect DrawingObjects:=True, Contents:=True,

    > > Scenarios:=True
    > > > > >
    > > > > > but again this only works without a password.
    > > > > >
    > > > > > Any ideas?
    > > > > >
    > > > > > --
    > > > > > Regards...
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >




+ 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