我想以编程方式确定用户是否在Visual Basic中使用表单时单击了右上方的“x”按钮。确定用户何时单击x-VBA
我曾尝试:
Private Sub nameOfForm_Exit()
'code goes here
End Sub
而一直未果。任何帮助将非常感激。
我想以编程方式确定用户是否在Visual Basic中使用表单时单击了右上方的“x”按钮。确定用户何时单击x-VBA
我曾尝试:
Private Sub nameOfForm_Exit()
'code goes here
End Sub
而一直未果。任何帮助将非常感激。
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
MsgBox "Good bye"
'/ To prevent user from closing the form
'/ Set cancel to True
Cancel = True
MsgBox "You can't close me!"
End Sub
QueryClose事件:https://msdn.microsoft.com/en-us/library/office/gg278635.aspx(甚至会告诉您用户是否按下了X或者窗体是以编程方式关闭还是...等等,以及允许您防止表单关闭,如果您愿意的话) – Mikegrann