delete task issue

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
 
J

Joy

and the strange thing is

when I delete a task that should be moved to the end of file. my msg box
will tell me that the task will be moved to the end of file. then the ms
project msgbox appears:
The selected item has some actual values.
Do you still want to delete it.

Yes No

if I click yes, it works as I expected
if I click no, the old task is still there, but the new task is deleted.
what I want is to delete the old one, and let new one just there.

thanks
 
J

Joy

thank you

well, I tried that, but seems still does not work

I debug it, it seems the MS project msg pops up after the it has exited the
sub.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top