Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
protect sheet in VB
Hi,
I want to use the below line lock a sheet ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True and assign a password. then the macro will hide the sheet. ActiveWindow.SelectedSheets.Visible = False Another Macro will unhide the sheet and then unlock it with a password prompt. ActiveWindow.SelectedSheets.Visible = False ActiveSheet.Unprotect but this does not work. I cannot assign a password on protecting. any ideas? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
protect sheet in VB
Mark, try this
ActiveSheet.Protect password:="123", DrawingObjects:=True, _ Contents:=True, Scenarios:=True or with a input box to select a password pw = InputBox("What password do you want to use ?") ActiveSheet.Protect password:=pw, DrawingObjects:=True, _ Contents:=True, Scenarios:=True -- 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 2000 & 97 ** remove news from my email address to reply by email ** "Mark Howard" wrote in message ... Hi, I want to use the below line lock a sheet ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True and assign a password. then the macro will hide the sheet. ActiveWindow.SelectedSheets.Visible = False Another Macro will unhide the sheet and then unlock it with a password prompt. ActiveWindow.SelectedSheets.Visible = False ActiveSheet.Unprotect but this does not work. I cannot assign a password on protecting. any ideas? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
protect sheet in VB
If you protect with code, and want a password, then the password is set with
code. There will be no prompt to set one. ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True Password:= "mypass" ActiveSheet.Unprotect Password:= "mypass" Also, to unhide a sheet use .Visible = True If someone tries to unprotect the sheet from the menu, they will get a prompt for the password. Hope this helps...Mike F "Mark Howard" wrote in message ... Hi, I want to use the below line lock a sheet ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True and assign a password. then the macro will hide the sheet. ActiveWindow.SelectedSheets.Visible = False Another Macro will unhide the sheet and then unlock it with a password prompt. ActiveWindow.SelectedSheets.Visible = False ActiveSheet.Unprotect but this does not work. I cannot assign a password on protecting. any ideas? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Bug - Protect Sheet ? | Excel Discussion (Misc queries) | |||
How to protect all sheet ? | Excel Worksheet Functions | |||
Protect Workbook Vs Protect Sheet | New Users to Excel | |||
Can I protect columns w/in a "List" using Protect Sheet? | Excel Discussion (Misc queries) | |||
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet | Excel Programming |