J
Joy
in ms project, if you want to delete a task, a msgbox will appear:
The selected item has some actual values.
Do you still want to delete it.
Yes No
Could you pleas tell me how to hide the msgbox?
I am writing a macro, and when I delete a task, I will have my own msgbox
out. now, every time after that, this ms project msgbox will also appear.
what I want to do is let my own msgbox appear, and that is all. the ms
project msg box will not appear.
I use"exit sub", and no help... thanks.
BTW, I do not know how to move a task, so i use copy it to a new task, and
delete the old task.
My code is as follows:
Public WithEvents App As Application
'Occurs before a task is deleted
Private Sub app_ProjectBeforeTaskDelete(ByVal tsk As task, Cancel As Boolean)
'MsgBox "Task will be moved to the end of file. ", vbExclamation
On Error Resume Next
If tsk Is Nothing Then
Exit Sub
End If
'task is required, and it cannot be deleted
If (Len(tsk.Text19) > 0 And tsk.Text19 = "false") Then
Cancel = True
MsgBox "You cannot delete a required task " & "'" & tsk.Name &
"'" & ".", vbExclamation
Exit Sub
'task is not required, but movable to the end of file
ElseIf (Len(tsk.Text29) > 0 And tsk.Text29 = "true") Then
Set nTsk = ActiveProject.Tasks.Add(tsk.Name)
'task is moved to the end of file
MsgBox "Task" & " '" & tsk.Name & "'" & " has started, so it
cannot be deleted. It will be moved to the end of this file. Its Dependency
will also be removed.", vbExclamation
Exit Sub
Else
'task is deleted
MsgBox "Task" & " '" & tsk.Name & "'" & " is neither started nor
complete. So it will be deleted.", vbExclamation
Exit Sub
End If
On Error GoTo 0
End Sub
The selected item has some actual values.
Do you still want to delete it.
Yes No
Could you pleas tell me how to hide the msgbox?
I am writing a macro, and when I delete a task, I will have my own msgbox
out. now, every time after that, this ms project msgbox will also appear.
what I want to do is let my own msgbox appear, and that is all. the ms
project msg box will not appear.
I use"exit sub", and no help... thanks.
BTW, I do not know how to move a task, so i use copy it to a new task, and
delete the old task.
My code is as follows:
Public WithEvents App As Application
'Occurs before a task is deleted
Private Sub app_ProjectBeforeTaskDelete(ByVal tsk As task, Cancel As Boolean)
'MsgBox "Task will be moved to the end of file. ", vbExclamation
On Error Resume Next
If tsk Is Nothing Then
Exit Sub
End If
'task is required, and it cannot be deleted
If (Len(tsk.Text19) > 0 And tsk.Text19 = "false") Then
Cancel = True
MsgBox "You cannot delete a required task " & "'" & tsk.Name &
"'" & ".", vbExclamation
Exit Sub
'task is not required, but movable to the end of file
ElseIf (Len(tsk.Text29) > 0 And tsk.Text29 = "true") Then
Set nTsk = ActiveProject.Tasks.Add(tsk.Name)
'task is moved to the end of file
MsgBox "Task" & " '" & tsk.Name & "'" & " has started, so it
cannot be deleted. It will be moved to the end of this file. Its Dependency
will also be removed.", vbExclamation
Exit Sub
Else
'task is deleted
MsgBox "Task" & " '" & tsk.Name & "'" & " is neither started nor
complete. So it will be deleted.", vbExclamation
Exit Sub
End If
On Error GoTo 0
End Sub