将“取消"设置为true后,VBA Workbook_BeforeClose仍会提示“保存"窗口.单击该菜单上的保存,然后关闭工作簿 [英] VBA Workbook_BeforeClose still prompts the Save window after setting Cancel to true. Clicking Save on that menu then closes the workbook

查看:58
本文介绍了将“取消"设置为true后,VBA Workbook_BeforeClose仍会提示“保存"窗口.单击该菜单上的保存,然后关闭工作簿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该问题是由我公司使用的自定义安全插件引起的.我对此无能为力,这是一个非常挑剔的问题,因此,我删除了该问题,以免使以后发现此问题的任何人感到困惑.

The issue is caused by a custom security addon that my company uses. Nothing I can do about it and is a very select problem, so I'm deleting the question so I don't confuse anyone who finds this in the future.

推荐答案

ActiveWorkbook 更改为 ThisWorkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)

    If ValidateData = True Then
        Call SendAndSave
    Else
        Select Case MsgBox("There are some invalid entries on the worksheet (values can only be between 0 and 5) so the changes were NOT " & _
            "sent to the server.  Do you still want to close the tool?", vbYesNo, "Warning")
        Case vbYes
            ThisWorkbook.Saved = True '/ won't ask the user to save
            ' but will still close.
        Case vbNo
            ThisWorkbook.Saved = True ''/ won't ask the user to save
            Cancel = True '/ Won't Close
        End Select
    End If

End Sub

这篇关于将“取消"设置为true后,VBA Workbook_BeforeClose仍会提示“保存"窗口.单击该菜单上的保存,然后关闭工作簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆