Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
cincode5
 
Posts: n/a
Default 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   Report Post  
Alan
 
Posts: n/a
Default

Try
ActiveSheet.Protect ("Your_Password")
Regards,
Alan.
"cincode5" wrote in message
...
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   Report Post  
cincode5
 
Posts: n/a
Default

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" wrote in message
...
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   Report Post  
Paul B
 
Posts: n/a
Default

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" wrote in message
...
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" wrote in message
...
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   Report Post  
cincode5
 
Posts: n/a
Default

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" wrote in message
...
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" wrote in message
...
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   Report Post  
Paul B
 
Posts: n/a
Default

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" wrote in message
...
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" wrote in message
...
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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Range Mess Karen Charts and Charting in Excel 18 January 14th 06 02:34 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
MACRO - copy rows based on value in column to another sheet Michael A Excel Discussion (Misc queries) 1 March 5th 05 02:15 AM
2 questions, copying data from sheet to sheet and assigning macro Boris Excel Worksheet Functions 0 December 16th 04 06:11 PM
Macro for multiple charts JS Excel Worksheet Functions 1 November 19th 04 03:44 AM


All times are GMT +1. The time now is 09:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"