【发布时间】:2015-09-02 20:43:54
【问题描述】:
我有一个简单的脚本,要求在关闭工作簿之前输入 密码(以防止意外关闭),但如果我输入正确的关键字,InputBox 会重新打开。我已经创建了以下脚本的多次迭代,但我无法解决它。
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
【问题讨论】: