本人在程式加了下面項目,但要如何存檔,並強制離開此程式??
Dim closeflag As Boolean
Private Sub workbook_beforeclose(cancel As Boolean)
If closeflag = False Then
cancel = True
MsgBox "此功能已經被禁止", vbExclamation, "提示"
End If
End Sub
Public Sub closeworkbook()
closeflag = True
Me.Close
End Sub
Private Sub workbook_beforesave(ByVal saveasul As Boolean, cancel As Boolean)
If saveasul = True Then
MsgBox "此檔案不允許另存新檔作業!!", vbOKOnly, "注意"
cancel = True
Else
cancel = False
End If
End Sub作者: Joforn 時間: 2016-10-16 13:37