M
MattH
Hi,
Using Project 2000 Standard, I'm trying to set task fields (one text
and one flag) whenever a task is changed or inserted, so am using the
ProjectBeforeTaskChange event.
I've set this up following the help text, so I have:
Created a new class module called EventClassModule, containing:
Public WithEvents App As Application
I'm connecting to this in my project using:
Dim X as New EventClassModule
Sub InitializeApp()
Set X.App=Application
End Sub
I call InitializeApp from the Project_Open event.
I then want to store the project's title in each new task's Text10
field, so use the following:
Private Sub App_ProjectBeforeTaskChange(ByVal tsk As Task, ByVal Field
As PjField, ByVal NewVal As Variant, Cancel As Boolean)
If Field=pjTaskName Then
tsk.Text10 = ActiveProject.BuiltinDocumentProperties("Title")
End If
End Sub
This works fine. I then want to flag the task as a milestone if it
appears in a certain section of the plan, so have amended the above
to:
Private Sub App_ProjectBeforeTaskChange(ByVal tsk As Task, ByVal Field
As PjField, ByVal NewVal As Variant, Cancel As Boolean)
If Field = pjTaskName And (tsk.OutlineParent.Name = "Work Package
Outputs (Deliverables)") Then
tsk.Milestone = "Yes"
Else
tsk.Text10 = ActiveProject.BuiltinDocumentProperties("Title")
End If
End Sub
This causes the follwoing behaviour:
1. If I stick to adding and changing tasks, everything works fine and
does what I want.
2. As soon as I do anthing else, like try to change the project's
properties or set an option, Project crashes. No errors, no nothing -
it just closes completely with no warning.
I assume I'm doing something really stupid? Can anyone please put me
right?
Many thanks in advance,
Matt
Using Project 2000 Standard, I'm trying to set task fields (one text
and one flag) whenever a task is changed or inserted, so am using the
ProjectBeforeTaskChange event.
I've set this up following the help text, so I have:
Created a new class module called EventClassModule, containing:
Public WithEvents App As Application
I'm connecting to this in my project using:
Dim X as New EventClassModule
Sub InitializeApp()
Set X.App=Application
End Sub
I call InitializeApp from the Project_Open event.
I then want to store the project's title in each new task's Text10
field, so use the following:
Private Sub App_ProjectBeforeTaskChange(ByVal tsk As Task, ByVal Field
As PjField, ByVal NewVal As Variant, Cancel As Boolean)
If Field=pjTaskName Then
tsk.Text10 = ActiveProject.BuiltinDocumentProperties("Title")
End If
End Sub
This works fine. I then want to flag the task as a milestone if it
appears in a certain section of the plan, so have amended the above
to:
Private Sub App_ProjectBeforeTaskChange(ByVal tsk As Task, ByVal Field
As PjField, ByVal NewVal As Variant, Cancel As Boolean)
If Field = pjTaskName And (tsk.OutlineParent.Name = "Work Package
Outputs (Deliverables)") Then
tsk.Milestone = "Yes"
Else
tsk.Text10 = ActiveProject.BuiltinDocumentProperties("Title")
End If
End Sub
This causes the follwoing behaviour:
1. If I stick to adding and changing tasks, everything works fine and
does what I want.
2. As soon as I do anthing else, like try to change the project's
properties or set an option, Project crashes. No errors, no nothing -
it just closes completely with no warning.
I assume I'm doing something really stupid? Can anyone please put me
right?
Many thanks in advance,
Matt