📅  最后修改于: 2022-03-11 14:51:53.512000             🧑  作者: Mango
' In the userform code (must also be command controls if any,
' for example buttons, for Keypress event)
Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 27 Then Unload Me
End Sub
' Or on at least one / all buttons:
button.Cancel = True
' Or if none add a button to the userform with:
With button
.Height = 0
.Width = 0
.Cancel = True
End Width