Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would like the prompt the user to input a password if the password
string variable does not already have a value. This is the code I currently have. Private Sub Worksheet_Activation(ByVal Target As Excel.Range) Dim PWORD As String If PWORD Is Nothing Then PWORD = InputBox("Enter protection password:", "Set Protection Password") End If ActiveWorkbook.Protect Password:=PWORD, Structu=True, Windows:=True ActiveSheet.Protect Password:=PWORD, DrawingObjects:=True, Contents:=True, Scenarios:=True ActiveSheet.EnableSelection = xlNoSelection Application.DisplayFormulaBar = False End Sub Perhaps I should move the prompt to Sheet1_Initialize()? Another problem I am having is that the PWORD string variable isn't being recognized by .Protect and .Unprotect. I have tried: ActiveWorkbook.Protect Password:=PWORD, Structu=True, Windows:=True and ActiveWorkbook.Protect (PWORD, True, True) They both do not work. Likewise for the ActiveWorkbook.Unprotect I have only about a week's worth of self-VBA training. haha Regards, Tim |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Data Protection- AKA: Sheet/Macro Password Protection | Setting up and Configuration of Excel | |||
password protection problem | Excel Discussion (Misc queries) | |||
Password Protection Problem | Excel Discussion (Misc queries) | |||
Prompt for protection password when not trying to access VBA | Excel Discussion (Misc queries) | |||
Excel 2003 Userinterfaceonly Password Protection Problem | Excel Programming |