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
'************
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