Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default How to password protect an application

I have an application for which I want the user to use a password
before being able to use it. I want the user to be able to make up to
three tries before terminating the application.
If I use an InputBox to prompt for the password the user can click
Cancel or Close and can get to the application worksheet without using
any password.
If I use a UserForm with a TextBox to enter the password how can I
display the password TextBox up to three times without unloading and
reloading the UserForm.
If wrong password the user would get a critical MsgBox which when
clicked OK would get, up to three times, immediately back to the
TextBox to re-enter the password.
Thanks for any help,
Nathan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default How to password protect an application

Hi Nathan

One way among several. Userform1 code (with a Textbox1 for entry and a CommandButton1
saying "OK" + default=true):

Option Explicit

Public Pwd As String

Private Sub CommandButton1_Click()
Pwd = TextBox1.Text
Me.Hide
End Sub

In a standard module:

Option Explicit

Sub Auto_open()
Dim Count As Long
Dim GoodGuy As Boolean
GoodGuy = False
For Count = 1 To 3
With UserForm1
Select Case Count
Case 1
.Caption = _
"Password please"
Case 2
.Caption = _
"Try again please"
Case 3
.Caption = _
"Last chance:"
End Select
.Show
If .Pwd = _
"Nathan Rules" Then
GoodGuy = True
Exit For
End If
End With
Next
Unload UserForm1
If GoodGuy = True Then
Sheets(1).Visible = True
MsgBox "Yo da man"
Else
Sheets(1).Visible = xlVeryHidden
ThisWorkbook.Save
ThisWorkbook.Close
End If
End Sub



Please don't MsgBox at wrong entries, thay have to be OK'ed away and are all over
extremely annoying. Use a label on the form, it's caption, color or whatever. Anything but
msgboxes.
--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Nathan Gutman" wrote in message
...
I have an application for which I want the user to use a password
before being able to use it. I want the user to be able to make up to
three tries before terminating the application.
If I use an InputBox to prompt for the password the user can click
Cancel or Close and can get to the application worksheet without using
any password.
If I use a UserForm with a TextBox to enter the password how can I
display the password TextBox up to three times without unloading and
reloading the UserForm.
If wrong password the user would get a critical MsgBox which when
clicked OK would get, up to three times, immediately back to the
TextBox to re-enter the password.
Thanks for any help,
Nathan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default How to password protect an application

John Wilson offers one suggestion in this thread.

http://www.google.com/groups?hl=en&l...ecc1a98&rnum=1

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

I have an application for which I want the user to use a password
before being able to use it. I want the user to be able to make up to
three tries before terminating the application.
If I use an InputBox to prompt for the password the user can click
Cancel or Close and can get to the application worksheet without using
any password.
If I use a UserForm with a TextBox to enter the password how can I
display the password TextBox up to three times without unloading and
reloading the UserForm.
If wrong password the user would get a critical MsgBox which when
clicked OK would get, up to three times, immediately back to the
TextBox to re-enter the password.
Thanks for any help,
Nathan


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default How to password protect an application

Thanks for the suggestions, I will look at them carefully.
There is another twist to that issue.
The worksheet will not require a password for the first 30 days from
the time that it was first opened. After that it will require a
password.
Thanks again,
Nathan
On Wed, 03 Dec 2003 13:01:37 -0700, am wrote:

John Wilson offers one suggestion in this thread.

http://www.google.com/groups?hl=en&l...ecc1a98&rnum=1

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

I have an application for which I want the user to use a password
before being able to use it. I want the user to be able to make up to
three tries before terminating the application.
If I use an InputBox to prompt for the password the user can click
Cancel or Close and can get to the application worksheet without using
any password.
If I use a UserForm with a TextBox to enter the password how can I
display the password TextBox up to three times without unloading and
reloading the UserForm.
If wrong password the user would get a critical MsgBox which when
clicked OK would get, up to three times, immediately back to the
TextBox to re-enter the password.
Thanks for any help,
Nathan


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
Password Protect ub Excel Worksheet Functions 1 January 14th 09 04:46 PM
VBA password protect brian thompson3001 via OfficeKB.com New Users to Excel 1 July 16th 06 07:23 PM
Password Protect cubsfan Excel Discussion (Misc queries) 0 April 7th 06 03:34 PM
How do I protect Visual Basic for Application Code Zagrijs Venter New Users to Excel 6 August 5th 05 09:24 PM
How do I protect my hidden Excel.Application object from unwanted user interaction. wijwoj Excel Programming 0 October 30th 03 04:49 PM


All times are GMT +1. The time now is 09:42 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"