View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Flanagan Bob Flanagan is offline
external usenet poster
 
Posts: 340
Default Password Boxes from xl95 to xl2000

Jim, you can re-write using a userform with a textbox. You can set the
textbox password character to a "*" so that the actual password does not
appear.

To display a userform, you would use a statement like

UserForm1.Show

To close the form, you would put the statement "Me.Hide" in a button's click
procedure. You access the click procedure by double clicking the button on
the form when in the VB editor. If you have an OK and a Cancel button, you
can set a public boolean variable to True if OK is clicked and False if the
Cancel button is clicked. Then, in your main calling procedure you check
this value immediately after the Show statement. You can also have the code
in the OK button procedure check to see if the password is valid before
closing the form.

Hope this helps,

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Jim" wrote in message
.. .
I have a customised excel package in xl95 which uses the old dialog boxes
for password protection. I need to update it now to xl 2000 onwards and

the
ability to
change the password, if necessary, by the user.
The old code is as below!
I'm not expecting anyone to rewrite it!!
Any ideas
Jim

<<Dim PassDialog, HiddenEB, DisplayEB
Dim PWord As String

Const Password = "manson"

Sub TillTakingsPassword()
Dim StayInLoop As Boolean
SetVariables
DisplayEB.Enabled = False 'Display box cannot be tabbed to
StayInLoop = True
While StayInLoop
HiddenEB.Text = ""
DisplayEB.Text = ""
PWord = ""
If PassDialog.Show Then
If PWord = Password Then
MsgBox "Welcome to the Masons Arms Daily Till Sheet",

4160,
"Masons Arms - Till Takings"
StayInLoop = False
TillTakingsSelect
Toolbars("Mats").Visible = True
Toolbars("Mats").Position = xlTop
Else
MsgBox "The password is not : " + PWord, 4112, "Masons
Arms - Till Takings"
End If
Else
MsgBox "Press OK to Exit", 4144, "Masons Arms - Till Takings"
StayInLoop = False
End If
Wend
End Sub

Sub MaskPassword()
PWord = HiddenEB.Text
DisplayEB.Text = String$(Len(PWord), "*")
End Sub

Sub SetVariables()
Set PassDialog = ThisWorkbook.DialogSheets("dboxTillTakingsPassword ")
Set HiddenEB = PassDialog.EditBoxes("HiddenEB")
Set DisplayEB = PassDialog.EditBoxes("DisplayEB")
End Sub
'Shows end of first password macro