我有一个简单的脚本要求在关闭工作簿(以防止意外关闭)之前需要密码,但如果输入正确的关键字,InputBox
将重新打开。我已经创建了以下脚本的多个迭代,但我无法解决它。VBA输入框提示两次
Sub Workbook_BeforeClose(Cancel As Boolean)
If InputBox("Please enter the password to close the workbook.") <> "pa55word" Then
MsgBox ("Incorrect password. Please try again")
Cancel = True
Exit Sub
Else
GoTo GoToClose
End If
GoToClose:
ThisWorkbook.Close SaveChanges:=False
End Sub
谢谢您的建议!我没有想到预先包含'.aved'部分。 – CJK