excel - VBA Before close event
问题描述
there is 2 events in my code i.e Before close,before save. in before save condition there are conditions to be filled before saving, else it wont allow to save. now while triggering before close, it will popup for save, dontsave, cancel message box. when selecting save, it will call before save function and it throws error message as like before save function. but after that file is closed.
Public Sub Workbook_BeforeClose(Cancel As Boolean)
Exit Sub
End Sub
解决方案
我想我误解了你试图描述的内容,但看看我下面的代码是否可以帮助你。
Public Sub Workbook_BeforeClose(Cancel As Boolean)
Select Case MsgBox("Select what do you want", vbYesNoCancel + vbExclamation, "Atention")
Case vbYes
Call Workbook_BeforeSave(True, False)
Case vbNo
Application.Quit
Case vbCancel
Cancel = True
End Select
Exit Sub
推荐阅读
- caddy - 将 caddy 用于域和 IP 地址时自动 https
- javascript - 运行 symfony encore 开始在 symfony 5.3 上使用 vue
- python - 纠正小错误
- angular - 如何在打字稿中获取方法返回类型
- python - 是否可以根据每次运行的内容向 ThreadPoolExecutor 提交函数调用?
- wordpress - product_categories Woocommerce 简码图像大小
- python - Seaborn:反向 cbar
- python - python Numppy数组获取最后3个值以识别其升序或降序或顺序
- ajax - 使用 index.html 时,由于 .htaccess 配置错误,JQuery ajax 抛出 403 禁止错误
- swift - 使用 CKQuery 列表获取结果