Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Password protect via VBA

3 views
Skip to first unread message

Mr. Password

unread,
May 21, 2003, 2:25:06 PM5/21/03
to
Hi all,

I am using VBA to protect a workbook and worksheets
altogether. I want the excel to show asterisks instead of
actual characters when the user enters password in the
input box. Is this possible to code?

My code is below.

Thank you,

GV


'********************
Sub ProtectAll()

Dim objSheet As Object
Dim szPassword1 As String, szPassword2 As String

szPassword1 = InputBox("This will protect the workbook and
ALL sheets." & vbNewLine _
& "Please enter a password (case sensitive):", "Protect
All")

szPassword2 = InputBox("Please re-enter the
password:", "Confirm password")

If szPassword1 = szPassword2 Then

Application.ScreenUpdating = False
ActiveWorkbook.Protect szPassword1

For Each objSheet In ActiveWorkbook.Sheets
objSheet.Protect szPassword1
Next objSheet

Application.ScreenUpdating = True

Else: MsgBox ("This password does not much the one
previously entered." & vbNewLine _
& "Please try again.")
End If

End Sub
'************

John Wilson

unread,
May 21, 2003, 2:36:40 PM5/21/03
to
GV,

An InputBox does not have the capability to mask the password.
If you really want to do this, create a UserForm with a TextBox.
A TextBox on a UserForm does have a property for PasswordChar

John

0 new messages