Pix*_*tic 17
一位同事能够提供答案,其中包括其他人的例子
Private Sub userform_terminate()
'Code goes here
End Sub
Run Code Online (Sandbox Code Playgroud)
MRS*_*367 14
您可以使用UserForm的QueryClose事件,如下所示:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
' Your codes
' Tip: If you want to prevent closing UserForm by Close (×) button in the right-top corner of the UserForm, just uncomment the following line:
' Cancel = True
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
你也可以像这样使用vbFormControlMenu:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
'Your code goes here
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
您可以在 VBA 中使用Unload Me来关闭窗体。只需紧接着输入关闭 Excel 的代码即可。
| 归档时间: |
|
| 查看次数: |
59796 次 |
| 最近记录: |