2016-11-25 76 views
0

我使用密碼保護工作表名稱「Profit Loss Statement」。它的運行良好,但密碼可以在打字時看到。所以我想掩蓋密碼。 這是我的代碼。如何掩蓋「工作表」輸入框的密碼

Private Sub Workbook_SheetActivate(ByVal Sh As Object) 
ActiveWorkbook.Unprotect 

Dim MySheets As String, Response As String 
Dim ex As Long 

MySheets = "Profit Loss Statement" 
If ActiveSheet.Name = MySheets Then 
    ActiveSheet.Visible = False 
    Response = InputBox("Enter password to view Profit & Loss") 
     If Response = "abcd" Then 'password is abcd and to be asked 
     Sheets(MySheets).Visible = True 
     Application.EnableEvents = False 
     Sheets(MySheets).Select 
     Application.EnableEvents = True 
     ActiveWorkbook.Protect 
     Else 
     MsgBox "Incorrect Password" 
     End If 
End If 
Sheets(MySheets).Visible = True 
ActiveWorkbook.Protect 
End Sub 
+0

可能重複的[不要在輸入框中看到密碼,但只有\ * \ * \ * \ * *](http://stackoverflow.com/questions/40598196/dont-see-the-password-in-inputbox -但只有) – Comintern

回答

0

我知道的是inputbox不能掩碼字符。在用戶窗體中使用文本框,並將其屬性「PasswordChar」等於*。