Sky86
09-23-2007, 07:16 PM
HI,
I need some help on this, i want to clean all the result before closing the excel file.
The code is like this,
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Please ensure to copy the result to a new excel before close," & Chr(10) & "or else the result will be delete. " & Chr(10) & "Do you want to close the application now? ", vbOKCancel, "Warning") = vbOK Then
Cleanrecord
ActiveWorkbook.Close (True)
End If
End Sub
The problem is, when i click the cancel button. Excel will save and close the workbook.
is there a way to stop the closing.
Thanks.
I need some help on this, i want to clean all the result before closing the excel file.
The code is like this,
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Please ensure to copy the result to a new excel before close," & Chr(10) & "or else the result will be delete. " & Chr(10) & "Do you want to close the application now? ", vbOKCancel, "Warning") = vbOK Then
Cleanrecord
ActiveWorkbook.Close (True)
End If
End Sub
The problem is, when i click the cancel button. Excel will save and close the workbook.
is there a way to stop the closing.
Thanks.