我正在尝试制作一个短代码,以便它可以检测外部用户并要求输入密码,但我不知道如何避免保存消息。
Private Sub Workbook_Open()
ThisWorkbook.Windows(1).Visible = False
If Application.UserName = "User1" Or Application.UserName = "User2" Then
Welc = MsgBox("Welcome " & Application.UserName)
ThisWorkbook.Windows(1).Visible = True
Exit Sub
Else
Pass = "1973"
Prompt = "Enter the password to continue"
Title = "Password Input"
UserPass = InputBox(Prompt, Title)
If UserPass <> Pass Then
Prompt = "You have entered an incorrect password"
Title = "Incorrect Passowd"
MsgBox Prompt, vbCritical, Title
ThisWorkbook.Close
Exit Sub
Else
Welc = MsgBox("Welcome " & Application.UserName)
ThisWorkbook.Windows(1).Visible = True
End If
End If
End Sub
我不知道Application.DisplayAlerts = False
Private Sub Workbook_Open()
ThisWorkbook.Windows(1).Visible = False
Application.DisplayAlerts = False
If Application.UserName = "User1" Or Application.UserName = "User2" Then
Welc = MsgBox("Welcome " & Application.UserName)
ThisWorkbook.Windows(1).Visible = True
Application.DisplayAlerts = True
Exit Sub
Else
Pass = "1973"
Prompt = "Enter the password to continue"
Title = "Password Input"
UserPass = InputBox(Prompt, Title)
If UserPass <> Pass Then
Prompt = "You have entered an incorrect password"
Title = "Incorrect Passowd"
MsgBox Prompt, vbCritical, Title
ThisWorkbook.Close
Exit Sub
Else
Welc = MsgBox("Welcome " & Application.UserName)
ThisWorkbook.Windows(1).Visible = True
Application.DisplayAlerts = True
End If
End If
End Sub