Update "Last Updated" Date Field if Any Task Item Changes

B

BJMar867

Good day!

I am new to VBA, so I hope you can help me. I am trying to use a macro to
automatically set a "Last Updated" field to today if any user updates their
information. We're basically tracking when people update their stuff.

I've followed the advice on http://masamiki.com/project/project_open.htm and
tried to use the App_ProjectBeforeTaskChange event, but it's not working.

Here's what I have so far, which is in a Class Module named TEvent under
"VBAProject (myProjectName)."

Public WithEvents App As Application

Private Sub App_ProjectBeforeTaskChange(ByVal tsk As Task, _
ByVal Field As PjField, _
ByVal NewVal As Variant, _
Cancel As Boolean)

If ((Field = pjText1) Or (Field = pjText2) Or (Field = pjText3) Or (Field =
pjText4) Or _
(Field = pjText5) Or (Field = pjText6) Or (Field = pjText7) Or (Field =
pjText8) Or _
(Field = pjText9) Or (Field = pjText10) Or _
(Field = pjText11) Or (Field = pjText12) Or (Field = pjText13) Or (Field
= pjText14) Or _
(Field = pjText15) Or (Field = pjText16) Or (Field = pjText17) Or (Field
= pjText18) Or _
(Field = pjText19) Or (Field = pjText20) Or (Field = pjText21) Or (Field
= pjText21) Or _
(Field = pjText22) Or (Field = pjText23) Or (Field = pjText24) Or (Field
= pjText25) Or _
(Field = pjText30) Or (Field = pjNumber1) Or (Field = pjNumber2) Or
(Field = pjNumber3) Or _
(Field = pjNumber4) Or (Field = pjNumber5)) And NewVal <> "Turnip" Then

pjDate1 = Today()

Cancel = True
End If
End Sub

I used "Turnip" because no one in their right mind would enter it, and I
don't know how to exclude "NewVal" from the equation. (Like I said, I'm a
total newbie.)

I also have this stored in "ThisProject" under "Microsoft Project Objects"
under "VBAProject (myProjectName)."

Thanks a million.

- BJ
 

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