LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protection Password Prompt Problem

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
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
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
password protection problem dpov Excel Discussion (Misc queries) 2 August 19th 09 10:22 PM
Password Protection Problem Duncan, UK Excel Discussion (Misc queries) 0 September 14th 06 03:53 PM
Prompt for protection password when not trying to access VBA Jamie B Excel Discussion (Misc queries) 0 July 13th 06 08:13 PM
Excel 2003 Userinterfaceonly Password Protection Problem [email protected] Excel Programming 1 June 8th 05 06:13 PM


All times are GMT +1. The time now is 10:06 AM.

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

About Us

"It's about Microsoft Excel"