LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default HOW can I add a PASSWORD entry box to my Excel app using VBA?

Marcello,

First you will have to create the userform with the buttons and
textboxes that you want. Then call the userform in the workbook_open
event.

Private Sub Workbook_Open()
UserFrom1.Show
End Sub

The code for the Submit button might look something like this:

Private Sub CommandButton1_Click()

Dim Str_Password As String

Str_Password = Sheets(1).Range("A1") 'You would of course have this
sheet hidden. You could also set the password here by replacing the
Sheets(1).Range("A1") with "Password", or what ever you select for the
password.

If TextBox1 = Str_Password Then
Unload Me
End If

If TextBox1 < Str_Password Then
Msgbox "Sorry, but you have entered an
incorrect password. Please re-enter the correct password.",vbOkayOnly +
vbCritical

TextBox1 = ""
TextBox1.SetFocus
Exit Sub
End If

End Sub

The code for the Cancel button might look something like this:

Private Sub CommandButton2_Click()

Application.DisplayAlerts = False
Application.Quit

End Sub

Hope this helps.


---
Message posted from http://www.ExcelForum.com/

 
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
Can I protect all excel tabs in a file with one password entry? Indiana born Excel Discussion (Misc queries) 40 December 17th 09 01:54 PM
sql server password entry during macro run Carl Irving Excel Discussion (Misc queries) 0 October 23rd 07 05:22 PM
password protecting a column for data entry in a sheet, how? kashi Excel Worksheet Functions 1 June 26th 07 03:09 AM
How can I add a PASSWORD entry box to my EXCEL app using VBA Marcello do Guzman Excel Programming 1 December 11th 03 08:05 AM
How to create a PASSWORD ENTRY BOX at startup of Excel Application Marcello do Guzman Excel Programming 1 December 8th 03 06:26 AM


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