|
|
|
date: Mon, 30 Jun 2008 08:51:41 -0700 (PDT),
group: microsoft.public.project.vba
back
Problem with Project Events
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
date: Mon, 30 Jun 2008 08:51:41 -0700 (PDT)
author: unknown
Re: Problem with Project Events
Hi Matt,
Try posting on the developer newsgroup as this one is closing down. Please
see FAQ Item: 24. Project Newsgroups. FAQs, companion products and other
useful Project information can be seen at this web
address:http://project.mvps.org/faqs.htm .
Mike Glen
Project MVP
matthills10@googlemail.com wrote:
> 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
date: Thu, 3 Jul 2008 22:41:07 +0100
author: Mike Glen glenATmvps.org
|
|