我已经编写了下面的代码,以便在关闭表单之前检查进程是否已完成。此用户窗体用作成绩单,将在子程序的最后一步中使
从我到目前为止在网上检查的内容来看,它应该可以工作。调试时,宏一直运行到 Cancel = True 的位置,并读取该行,但表单仍然关闭。
为什么即使读取该行,取消也没有被注册?
range("A6")
变为绿色以表示通过,或使range("B6")
变为红色以表示失败,然后卸载表单。从我到目前为止在网上检查的内容来看,它应该可以工作。调试时,宏一直运行到 Cancel = True 的位置,并读取该行,但表单仍然关闭。
为什么即使读取该行,取消也没有被注册?
Private Sub Userform_queryclose(CloseMode As Integer, Cancel As Integer)
Dim wbScoreCard As Workbook
Dim wsScoreCard As Worksheet
Dim MSG As String
Set wbScoreCard = Workbooks(NameBox.Value)
Set wsScoreCard = wbScoreCard.Worksheets(Format(Date, "MM.dd.yy") & " " & CallType.Caption)
If Err.Number = 0 Then
If wsScoreCard.Range("A6").Interior.Color <> vbGreen Then
If wsScoreCard.Range("B6").Interior.Color <> vbRed Then
Beep
MSG = MsgBox("This scorecard is not complete! If you close it now, this scorecard will not be saved. Continue?", vbYesNo, "Warning - Scorecard Incomplete")
If MSG = vbYes Then
wbScoreCard.Close savechanges:=False
Exit Sub
Else
Cancel = True
Exit Sub
End If
End If
End If
End If
End Sub
Cancel
是一个整数,而最终你将其设置为 true(1)?Cancel
在做什么? - BruceWayne